The MU forums have moved to WordPress.org

user id (14 posts)

  1. frankpanko
    Member
    Posted 18 years ago #

    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?

  2. frankpanko
    Member
    Posted 18 years ago #

    Never mind. I found a solution:

    <?php global $blog_id;?>
    ID: <?php echo $blog_id ?>

  3. maxius
    Member
    Posted 18 years ago #

    That's the blog id, not the user id. Users *could* have multiple blogs.

  4. suleiman
    Member
    Posted 17 years ago #

    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.

  5. drmike
    Member
    Posted 17 years ago #

    Find the function get_currentuserinfo() a call should be in there. We use it here for an example:

    http://trac.mu.wordpress.org/wiki/FancyLogin

  6. lunabyte
    Member
    Posted 17 years ago #

    global $current_user;
    echo $current_user->ID;
  7. suleiman
    Member
    Posted 17 years ago #

    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.

  8. lunabyte
    Member
    Posted 17 years ago #

    "Does anyone know where to get the current user's id..."

    That's what was asked for, and so returned.

  9. suleiman
    Member
    Posted 17 years ago #

    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!

  10. MrBrian
    Member
    Posted 16 years ago #

    "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?

  11. suleiman
    Member
    Posted 16 years ago #

    MrBrian, download my avatar pack and you'll find the necessary code in the author profile widget I bundled.

  12. MrBrian
    Member
    Posted 16 years ago #

    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;

  13. theapparatus
    Member
    Posted 16 years ago #

    Answered in your other thread. Please don't multi post as all you do is create more work for those helping out here.

  14. cmepthuk
    Member
    Posted 16 years ago #

    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

About this Topic

  • Started 18 years ago by frankpanko
  • Latest reply from cmepthuk