• Hey guys,
    I am looking for a function that checks if the user has a blog or is a blog user (or site, I forgot the technical term now that its changed.)

    I see is_site_admin, but I am not sure if that is the site/blog admin or the actual website.

    Anyone have more insight?

Viewing 7 replies - 1 through 7 (of 7 total)
  • is_site_admin is deprecated, WP3 uses is_super_admin – wp-includes/ms-deprecated.php

    is_user_member_of_blog will return true or false – wp-includes/ms-functions.php

    Thread Starter roastlechon

    (@roastlechon)

    Is there something that returns true if a user is the original blog admin?

    current_user_can

    https://codex.www.ads-software.com/Roles_and_Capabilities

    Example:

    if(current_user_can('manage_options') {
    // do stuff only blog Administrators can do
    } else {
    // do something everyone can do
    }

    Not sure what you mean by “original blog admin” but I use this to return the username and avatar of the admin email user:

    $id = $current_blog->blog_id;
    $user_id_from_email = get_user_id_from_string( get_blog_option($id, 'admin_email'));
    $details = get_userdata($user_id_from_email);
    echo get_avatar( $details->user_email, 32 ).' ';
    echo $details->user_firstname.' ' . $details->user_lastname.'<br />';

    So putting those to notions together, I could change the output based on whether the user logged in the “owner” of the blog

    $id = $current_blog->blog_id;
    $user_id_from_email = get_user_id_from_string( get_blog_option($id, 'admin_email'));
    
    if($current_user->id == $user_id_from_email) {
    echo get_avatar( $details->user_email, 32 ).' ';
    echo $details->user_firstname.' ' . $details->user_lastname.'<br />';
    } else {
    echo get_avatar( 'default', 32);
    }
    Thread Starter roastlechon

    (@roastlechon)

    Thanks
    I think that might be what I am looking for.

    What I mean by “original blog admin” is the user that originally owns/manages the blog.

    Say like I create a user “joe1” with a blog.
    I add other users, “john1” and “john2”.
    “joe1” would be considered the original blog admin.

    So I am thinking that with what you said, anyone who has the “manage_options” permission is the blog administrator. But what other permission is unique about the original blog admin that we could add in conjunction to “manage_options”?

    https://codex.www.ads-software.com/Roles_and_Capabilities

    “manage_options” is a cap all blog admins share:
    There are no permissions associated with the admin_email user, unless you code them yourself.

    activate_plugins
    create_users
    delete_others_pages
    delete_others_posts
    delete_pages
    delete_plugins
    delete_posts
    delete_private_pages
    delete_private_posts
    delete_published_pages
    delete_published_posts
    delete_users
    edit_dashboard
    edit_files
    edit_others_pages
    edit_others_posts
    edit_pages
    edit_plugins
    edit_posts
    edit_private_pages
    edit_private_posts
    edit_published_pages
    edit_published_posts
    edit_themes
    edit_theme_options
    edit_users
    import
    install_plugins
    install_themes
    manage_categories
    manage_links
    manage_options
    moderate_comments
    publish_pages
    publish_posts
    read
    read_private_pages
    read_private_posts
    switch_themes
    unfiltered_html
    unfiltered_upload
    update_plugins
    update_themes
    upload_files

    Oh, a couple of those caps get bumped up to the Super Admin Role in a multisite install: edit_themes, edit_plugins, install_plugins, install_themes, etc.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Is Blog Admin or Site Admin’ is closed to new replies.