Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

My site has a user profile page. For some reason I would like to pull user profile data in my plugin.

I know I can pull logged in user profile data using get_currentuserinfo();.

For example I would like to get displayed profile user id.

Can anyone tell me how to pull it.?

share|improve this question
add comment

3 Answers 3

up vote 1 down vote accepted

If you're trying to get user data for the displayed profile, you can do it like so:

$thisauthor = get_userdata(intval($author));

That'll return an object filled with everything you need. For instance, if you need the user ID, you can call it like so:

$thisauthor->ID

I use this extensively on the profiles on my site: http://androidandme.com/user/clark

UPDATE

In a plugin, it looks like you need to call the global variable first, like so:

global $author; $thisauthor = get_userdata(intval($author));

share|improve this answer
    
But the problem is I need the profile id value within a plugin. I've tried your code already. Its not working within a plugin. –  Giri Nov 3 '12 at 17:46
    
Finally I end up using sessions to store the current profile ID. By the way can you help me with this question ? –  Giri Nov 3 '12 at 17:49
    
Does adding a global $author help anything? –  clark Nov 3 '12 at 17:57
    
You are diamond mate. It works when I add global variable!!! Thanks –  Giri Nov 3 '12 at 18:11
add comment

Take a look at:

get_user_by() at http://codex.wordpress.org/Function_Reference/get_user_by

share|improve this answer
add comment

You can access your wp_users table using WP_User_Query. http://codex.wordpress.org/Class_Reference/WP_User_Query

For example:

$author_query = new WP_User_Query();

// Get the results
$authors = $author_query->get_results();

A more comprehensive example can be seen here: http://wpsmith.net/2012/wp/an-introduction-to-wp_user_query-class/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.