• Resolved Burke Ingraffia

    (@mobile251)


    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.

Viewing 10 replies - 1 through 10 (of 10 total)
  • 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 />';
    ?>

    Thread Starter Burke Ingraffia

    (@mobile251)

    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

    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.

    Thread Starter Burke Ingraffia

    (@mobile251)

    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.

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

    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()){...}

    Thread Starter Burke Ingraffia

    (@mobile251)

    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?

    Thread Starter Burke Ingraffia

    (@mobile251)

    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?

    <?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”.

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

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How do you retrieve the admin id of a particular multisite blog?’ is closed to new replies.