Home > wp query > How can I echo out the user id in user meta?

How can I echo out the user id in user meta?

December 10Hits:1
Advertisement

I need to generate a unique ID number for each new member. I was going to use WP_query, but am not getting anything but an array.

Answers

If you want to display the info on the current user logged in you can use get_currentuserinfo. [Codex]

Example from Codex

<?php global $current_user;
      get_currentuserinfo();

      echo 'Username: ' . $current_user->user_login . "\n";
      echo 'User email: ' . $current_user->user_email . "\n";
      echo 'User first name: ' . $current_user->user_firstname . "\n";
      echo 'User last name: ' . $current_user->user_lastname . "\n";
      echo 'User display name: ' . $current_user->display_name . "\n";
      echo 'User ID: ' . $current_user->ID . "\n";
?>

Or if you want display the info for a user that is not the current user logged in, you can use get_userdata. [Codex]

The two links to the WP Codex should provide you with the syntax of the two functions. If you have any further questions or they did not work please ask.

Tags:wp query

Related Articles

  • How can I echo out the user id in user meta?December 10

    I need to generate a unique ID number for each new member. I was going to use WP_query, but am not getting anything but an array. --------------Solutions------------- If you want to display the info on the current user logged in you can use get_curre

  • Echo page title from page with custom meta datetime pickerDecember 21

    I am using Custom Metaboxes and Fields for Wordpress I am using the datetime_timestamp custom meta with a page. I am trying to echo the title of the page I am using the custom meta datetime in. But it is not working. I have the code incorrect. And I

  • echo or print_r in an admin functionMarch 31

    I'm currently working my first plugin (to deal with my CPT) and am at the process of saving the values of a meta box. I wish to add an underscore (_) to the meta key so that it is hidden on the custom field part. I have some trouble to get the data s

  • get_post_meta inside echo December 30

    I have a serious problem :) I have this code: <?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'provinciadestacada', true); ?> And i want include here: <?php if ( in_category( '951' )) { echo 'Online'; } el

  • Custom Taxonomy not working with posts_per_page in new WP_query (pagination problem)May 4

    OK, so i'm messing with Custom Taxonomies for the second time and in both instances i've run into this problem where using the posts_per_page argument in either a query_posts or WP_query scenario.. basically, if i set a custom limit on posts per page

  • Bash: Quotes getting stripped when a command is passed as argument to a functionMay 13

    I am trying to implement a dry run kind of mechanism for my script and facing the issue of quotes getting stripped off when a command is passed as an argument to a function and resulting in unexpected behavior. dry_run () { echo "[email protected]" #printf '%q

  • wp_handle_upload error "Specified file failed upload test" but still creates attachment?July 18

    Having a bit of trouble with an image upload custom meta box. What happens is the uploaded image is created as an attachment but the wp_handle_upload seems to kick back the error "Specified file failed upload test" rather than updating my post m

  • Conversion of datetime strings in PHP pages to user's timezoneJuly 19

    I am working on a PHP/MySQL application that uses a different time zone from the server it runs on, and neither of the timezones are UTC. I'm converting displayed times to be in the user's timezone, and am wondering whether my approach is sensible. I

  • Eliminating the appearance of a specific custom field in a postOctober 16

    I would like to suppress the output of one of my custom fields. Is there a way to do this using the <?php the_meta(); ?>command? --------------Solutions------------- The function, the_meta() allows you to hook to the the_meta_key filter (which curre

  • Category pagination not workingNovember 28

    My category page navigation doesn't seem to be showing up at all, what am I missing in my coding? <?php get_header(); ?> <div class="inner-page"> <div class="page-spacer"></div> <!-- Content Start --> <

  • Output from Meta Box ArrayFebruary 15

    I have created a meta box and it's storing the post data successfully but I am having trouble outputting the content and displaying it in a sensible fashion - beyond my limited knowledge of PHP. I am a bee-keeper and want to record inspections of my

  • wp_editor not adding paragraphs despite wpautop being set to trueMay 6

    I'm using the following code to produce a wp_editor instance: <?php if (version_compare($wp_version, "3.3") >= 0) { ?> <p><?php wp_editor( $answer->post_content, 'answer', array( 'media_buttons' => true, 'wpautop' => t

  • Prev/Next child navigation for current page?June 7

    How can I get a Previous / Next navigation that only navigates the child pages of the current page? By that i mean url.com/page/child1, url.com/page/child2 and so on.. I've been searching around alot but I'm still lost. It seems like you can't do tha

  • Show array of meta_value in Edit Post ColoumJuly 1

    what I'm trying to do is add a new coloumn to Edit post page (done) and in that coloumn show data taken from a set of custom fields (partially done). This is my code (I use it as a plugin so it simpler to modify it). It adds the metabox in posts so I

  • metaboxes disappear on saved pagesJuly 26

    Ok I have a wierd issue with custom meta boxes that I am at a loss for. I am using this class <?php class ARIXWP_Meta { private $meta = null; public $postid = null; private $template = null; function __construct() { add_action('save_post',array(&$t

  • How to add all categories into an array and extract the categories names and use it with a custom meta box

    How to add all categories into an array and extract the categories names and use it with a custom meta boxDecember 5

    Basically I need to add custom meta boxes to pages and one of this options must be a list of categories from previous posts. I've managed to add the metaboxes and wrapped the categories in a array, however there must be something I missing as on the

  • Listing wordpress users with a search functionMarch 14

    I'm having trouble finishing off this code that I adapted from Cosmoslabs excellent tutorial. Everything is working (listing and pagination etc) except the search function whic is returning nothing i.e. no users are listed when I try to filter by a k

  • How to update/delete array in post meta value?May 14

    I using post meta like.. $meta = get_post_meta(99,'_mymeta',true); $value = $meta['somekey']; echo $value; But how to update $meta['somekey'] to some another value ? How to use update_post_meta to update sub meta key ?(Idk, How ppl call) update_post_

  • Repeatable custom meta select boxesJune 12

    I am working on meta fields for a custom post type storing match data. I have two sepearte meta boxes one which the team and the score are chosen and the values are submitted. The second takes that information and provides a series of select boxes in

  • How to hide post metaJuly 12

    I have disqus installed in my website. It adds dsq_thread_id meta. And while showing the post meta in post with tag; <?php the_meta(); ?> I want to hide dsq_thread_id in all posts. How can I do this? --------------Solutions------------- OK, just don

Copyright (C) 2018 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.406 s.