The MU forums have moved to WordPress.org

need to make a plugin appear only in the site admin menu (5 posts)

  1. alliancepro
    Member
    Posted 17 years ago #

    hi
    how to make a plugin appear only in the admin menu and not to the all users ?? i have tryed many thing :
    is_site_admin();
    puting it in mu-plugin
    and many athers thing

    have you an idea please ??

  2. DrkWrz
    Member
    Posted 17 years ago #

    Hi I made something like that, I don't know if its the best solution.

    function get_userinfo(){
    global $wpdb;
    if (!isset($_COOKIE[wordpressuser_]))
    return false;
    $sql = "SELECT ID FROM $wpdb->users WHERE user_login='".$_COOKIE[wordpressuser_]."'";
    $user_data = $wpdb->get_row($sql);
    return $user_data;
    }

    $user_info = get_userinfo();
    //Mi Admin is the user with ID 1
    if($user_info->ID==1){

    }

  3. andrea_r
    Moderator
    Posted 17 years ago #

    There's a plugin in this thread which is admin only, so you might want to grab it and have a look at how it was done.

  4. alliancepro
    Member
    Posted 17 years ago #

    thanks for your help , but i have found another solutions , it work for me and i use it with the mightyadsense plugin to display ads in user blogs without show the admin interface .

    function mightyadsense_admin_menu() {
    $pfile = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
    if ( is_site_admin() )
    add_submenu_page('wpmu-admin.php', 'adsense', 'adsense', 0, $pfile,'mightyadsense_options_page');
    }
    it show the plugin under the site admin menu so it will show only for admin
    if any one find that usefull and need some help with it just ask for it

  5. tsukaeru
    Member
    Posted 17 years ago #

    Does "if ( is_site_admin() )" work for you in a plugin? It doesn't seem to return the correct value.

About this Topic

  • Started 17 years ago by alliancepro
  • Latest reply from tsukaeru