• Resolved trape

    (@trape)


    Hi,

    I have WP 3.5 with 3 roles: Suscriptor, Administrator, Editor
    I want to hide ALL menu of subscriber2 (Settings, Send, User, Manage) for user role ‘Suscriptor’, and I want to enable these 4 menus only for user role ‘Administrator’ and ‘Editor’.

    I made these code in ‘susbriber2.php’

    function s2_admin_changes( $capability, $menu ) {
    
        global $current_user;
    
        $user_roles = $current_user->roles;
        $user_role = array_shift($user_roles);
    
        //MENU PREFERENCIAS PERSONALES
        if ( $menu == 'user' ) {
    
        	if($user_role=='Administrator' || $user_role=='Editor'){
        	    return 'read';
        	}
    
        }
    
        if ( $menu == 'manage' ) {
    
        	if($user_role=='Administrator' || $user_role=='Editor'){
        	    return 'read';
        	}
    
        }
    
        if ( $menu == 'settings' ) {
    
        	if($user_role=='Administrator' || $user_role=='Editor'){
        	    return 'read';
        	}
    
        }
    
        //MENU ENVIAR CORREO PRUEBA
        if ( $menu == 'send' ) {
    
        	if($user_role=='Administrator' || $user_role=='Editor'){
        	    return 'read';
        	}
    
        }
    
        return $capability;
    }
    add_filter('s2_capability', 's2_admin_changes', 10, 2);

    Works but ‘Subcriptor’ can view menu ‘user’ (User preferences). I know about WordPress and roles & capabilitys, but I want to ask that it is possible to change capability (new capabilty that I create) for view menu ‘user’ in subscriber2? Or there is any way easy to hide these menu ‘user’ for my role ‘Suscriptor’ ?

    Thanks in advance!!

    http://wordpress.org/plugins/subscribe2/

Viewing 7 replies - 1 through 7 (of 7 total)
  • @trape,

    You are using the right filter approach but none of your if statements handle the ‘Subscriber’ user role so it will be returning the Subscribe2 default. I think you need to account for the ‘subscriber’ role in your code.

    Thread Starter trape

    (@trape)

    @mattyrob

    You have reason. I fix these:

    if($user_role=='Administrator' || $user_role=='Editor'){
    
          return $capability;
    
       }

    And works perfectly. Thanks!

    @trape,

    Great news, I’m glad you have it working as you like.

    I also need help!
    But, I don’t understand, what code and on which line in ‘susbriber2.php’ should I to put code.

    Thanks in advance!!

    @polkin,

    I would suggest creating your own plugin or maybe using the functions.php file of your theme. Creating your own plugin means you don’t lose changes between plugin or theme updates.

    @mattyrob,

    Ok, can you give the code to be inserted in the functions.php, that will give the editor entitled to see the plugin menu, as administrator?

    @polkin,

    I could but why don’t you have a try yourself first. I already provide the Subscribe2 plugin and support on here free of any charge and I expect users to try customisations themselves rather than expecting site specific changes on their sites for free as well.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Menu's and capability's problem’ is closed to new replies.