Forums

[resolved] How do you retrieve the admin id of a particular multisite blog? (11 posts)

  1. mobile251
    Member
    Posted 1 year ago #

    I found out how to get the current blog id by using:

    $thisblog = $current_blog->blog_id;

    But how do I get the admin id of $thisblog ?

    I thought maybe it was with the function

    get_admin_users_for_domain($thisblog);

    but I can't get it to work.

    ********************************

    The reason I am trying to get this info, is that I want to display admin user meta on the index.php page of each multisite blog. Maybe there is a really really simle way that I am overlooking.

  2. David Sader
    Member
    Posted 1 year ago #

    How about this?

    <?php
    			$user_id_from_email = get_user_id_from_string( get_blog_option($thisblog, 'admin_email'));
    			$details = get_userdata($user_id_from_email);
    			echo get_avatar( $details->user_email, 32 ).' ';
    			echo $details->user_firstname.' ' . $details->user_lastname.'<br />';
    			echo $details->user_email.'<br />';
    			echo $details->user_url.'<br />';
     			echo 'ID=' . $details->ID . ', ' . $details->user_login . ', ' . $details->user_nicename . ', ' . $details->display_name . ', ' . $details->user_nickname . '<br />';
    			echo 'Registered=' . $details->user_registered.'<br />';
    			if ($details->aim) echo 'aim=' . $details->aim.'<br />';
    			if ($details->yim) echo 'yim=' . $details->yim.'<br />';
    			if ($details->jabber) echo 'jabber=' . $details->jabber.'<br />';
    			if ($details->description) echo 'description=' . $details->description.'<br />';
    ?>
  3. mobile251
    Member
    Posted 1 year ago #

    David

    Thanks!! - I will get back to you on this. Initially the desired user ID is 4 and this code is displaying 3. Maybe I am doing it wrong. Let me play with it a little.

    Burke

  4. David Sader
    Member
    Posted 1 year ago #

    The blog option admin_email comes from the blog Dashboard->Settings->General and is filled in on creation of the site(or later). That admin_email in your case may not be the same as the user_email you have set as the administrator.

    How about this?

    <?php
    $admins = get_admin_users_for_domain();
    foreach($admins as $admin) {
    	$details = get_userdata($admin['ID']);
    	echo 'Admin Email: '. $details->user_email;
    // etc etc etc
    }
    ?>

    EDIT!!
    Nevermind: get_admin_users_for_domain() only lists Super Admins aka admin_user_id from site_meta aka Network Options.

  5. mobile251
    Member
    Posted 1 year ago #

    David

    But if there is only one Super Admin, is there a way to write:

    If not Admin (id=1) then echo 'etc, etc'

    or maybe if Admin id != 1 then echo 'etc, etc'

    ******************************

    The other thought is to not attach the meta to the admin, but to the blog itself. Do you know of a way to add another custom field like blog name or blog description to the blog itself?

    Thanks for your help. Truly.

  6. Andrea_r
    team pirate
    Posted 1 year ago #

    Are you trying to display the blog name or description on the front side of the blog? there's template tags for that.

  7. David Sader
    Member
    Posted 1 year ago #

    Bloginfo tags display blog name and description:

    The usual themes call bloginfo in the header.php
    http://codex.wordpress.org/Function_Reference/bloginfo

    To your original question: the blog's admin user id.

    A blog may have several(or none) users with administrator role, but only one email is ever the admin_email at Dashboard->Settings->General

    $user_id_from_email = get_user_id_from_string( get_blog_option($thisblog, 'admin_email'));
    or
    $user_id_from_email = get_user_id_from_string( get_option('admin_email'));

    BTW, SuperAdmin checks:
    Common check of the logged in user I use:

    if(is_super_admin()){...}
    if(!is_super_admin()){...}
  8. mobile251
    Member
    Posted 1 year ago #

    Thanks Andrea and David

    Both of your comments have been helpful.

    I know about this:

    <?php bloginfo('name'); ?> AND <?php bloginfo('description'); ?>

    But is there such a thing like

    <?php bloginfo('custom_blog_meta'); ?>

    that can be created as a function?

  9. mobile251
    Member
    Posted 1 year ago #

    David,

    This solved my first question perfectly:

    <?php
    $thisblog = $current_blog->blog_id;

    $user_id_from_email = get_user_id_from_string( get_blog_option($thisblog, 'admin_email'));

    echo 'Admin ID is '. $user_id_from_email;

    ?>

    But I still would like to know from the above reply:

    Is there such a thing like

    <?php bloginfo('custom_blog_meta'); ?>

    that can be created as a function?

  10. David Sader
    Member
    Posted 1 year ago #

    <?php echo get_option('custom_blog_meta'); ?>

    http://codex.wordpress.org/Creating_Options_Pages
    http://codex.wordpress.org/Settings_API

    Plugins add blog options to db in a variety of ways.

    Time to start a new thread if you've resolved the op " the admin id of a particular multisite blog".

  11. skywolfyx1
    Member
    Posted 1 year ago #

    @david sader, thank you, i will use your codes
    take care

Topic Closed

This topic has been closed to new replies.

About this Topic