I'm working on a multiuser plug-in but haven't been able to fingure out where to get the user's id.
Does anyone know where to get the current user's id for a page that will aear in the options panel?
I'm working on a multiuser plug-in but haven't been able to fingure out where to get the user's id.
Does anyone know where to get the current user's id for a page that will aear in the options panel?
Never mind. I found a solution:
<?php global $blog_id;?>
ID: <?php echo $blog_id ?>
That's the blog id, not the user id. Users *could* have multiple blogs.
and they often do. And often times blogs get deleted but users don't.
So the question still stands if anyone is there who can answer it.
Find the function get_currentuserinfo() a call should be in there. We use it here for an example:
global $current_user;
echo $current_user->ID;
folks, this code
global $current_user;
echo $current_user->ID;
will only return the information for the logged in user. It will not do any justice in returning data for the blog owner.
"Does anyone know where to get the current user's id..."
That's what was asked for, and so returned.
my bad luna, thanks for your correct reply. I've since figured out how to get the blog_id information.
Will be releasing a WPMU Avatars pack once i'm done with all this!
"It will not do any justice in returning data for the blog owner."
Could you explain how to get user information of the blog owner, not the currently logged in user using blog_id or another method?
MrBrian, download my avatar pack and you'll find the necessary code in the author profile widget I bundled.
I took a look and it seems to pull the user_id from the picture file used for the avatar (and then pulls the user info with the get_userdata function), which seems like a dedicated solution used for the avatar pack. I put my nose to the grindstone for a solution to this that didn't require a crutch to lean on, and the solution i came up with was to pull the user_id from the usermeta table based on the $domain variable, which is variable initialized at the start:
global $domain;
$user_id = $wpdb->get_var("SELECT user_id FROM wp_usermeta WHERE (meta_key = 'source_domain' AND meta_value = '$domain')");
$user_info = get_userdata($user_id);
echo "Login: ".$user_info->user_login;
Answered in your other thread. Please don't multi post as all you do is create more work for those helping out here.
How to get admin user_id per blog_id? Easy:
$adm_id = $wpdb->get_var("select ID from wp_users WHERE user_email = '".get_blog_option($details['blog_id'],'admin_email')."'");
Where $details['blog_id'] - id of needed blog