Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #3737
    Vladimir
    Keymaster

    Hi Frederik,

    Good point! Fixed. Try the updated beta version 4.34.2.b3

    #3738
    Oxfam
    Participant

    Works great!

    (Changed the required capability to ‘promote_users’ for my needs.)

    #3791
    [email protected]
    Participant

    Vladimir,

    Clicking on Grant Roles, pops up the window with Primary Role and Secondary roles- but the user’s roles are not pre-selected. I think the previously set roles should be selected before the user starts to make changes. Can you check on that please?

    #3792
    Vladimir
    Keymaster

    I did not select current role(s) at “Grant Roles” dialog as I positioned this feature for the bulk action. There is no sense to pre-select current roles when action is applied to multiple users at once.

    But I agree with you such pre-selection will enhance usability if action is applied to a single user. I will update a code to work this way. Thanks.

    #3833
    [email protected]
    Participant

    Vladimir,

    I finally got to setting this up. I’ve applied the filter to return true using the code for user with role ‘ga_site_administrator’. I tried to debug, and added some debug statements in classes/grant-roles.php

    FILTER TO ALLOW GRANT ROLES FOR EDIT_USERS

    
    add_filter('ure_bulk_grant_roles', 'ga_show_ure_bulk_grant_roles');
    function ga_show_ure_bulk_grant_roles($show) {
        
        if(current_user_can_for_blog(null, 'ga_site_administrator') && !ga_is_super_admin())
        {
           $show = TRUE;
           echo " Show GRANT ROLES ";
        }
        
    
        return $show;
    }
    

    GRANT ROLES CODE:

    
     public function show_grant_roles_html() {
            if (!$this->lib->is_right_admin_path('users.php')) {
                return;
            }
            if (!current_user_can('edit_users')) {
                echo " IN show_grant_roles_html ".current_user_can('edit_users');
                if(current_user_can('ga_site_administrator'))
                            echo " use has ga_site_administrator";  
                print_r(get_role('ga_site_administrator' )->capabilities);   
    
                return;
            }
    ?>        
    

    Grant Roles - edit_users capability still doesn't show up

    #3834
    [email protected]
    Participant

    FYI: To test, I removed edit_users in this function, and replaced with the custom role-‘ga_site_administrator’ — and Grant Roles showed up. However, since it’s in the plugin code, it should be fixed there.. eventually. What could be going wrong?

    
     public function show_grant_roles_html() {
            if (!$this->lib->is_right_admin_path('users.php')) {
                return;
            }
            if (!current_user_can('ga_site_administrator')) {
    

    Image didn’t get included earlier.. trying again.

    The bug it seems is that it’s not passing !current_user_can(‘edit_users’), even even the capabilities listed for the user show that edit_users => 1

    grant roles

    #3836
    Vladimir
    Keymaster
    
    if (!$this->lib->is_right_admin_path()
    

    $this->lib object is not defined inside your function. So you get a PHP fatal error here and code is not executed further.

    You have to use it this way:

    
    $lib = URE_Lib_Pro::get_instance();
    if (!$lib->is_right_admin_path('user.php') {
    
    #3838
    [email protected]
    Participant

    Vladimir,

    This is the grant-roles.php file in the plugin code. I was just modifying it to debug.
    The contructor instantiates $lib, and within show_grant_roles_html, its used as $this->lib, which passes through and works.

    
     public function __construct() {
            
            $this->lib = URE_Lib::get_instance();   
    
       
        public function show_grant_roles_html() {
    
            if (!$this->lib->is_right_admin_path('users.php')) {      
    	    return;
            }   
    	   
           // if ( !current_user_can('edit_users')) {
            if ( !current_user_can('edit_users')) {
                /*echo " IN show_grant_roles_html ".current_user_can('edit_users');
    	    if(current_user_can('ga_site_administrator'))
    			echo " use has ga_site_administrator";	
                print_r(get_role('ga_site_administrator' )->capabilities);   
    	    */
    
    		return;
            }
    

    The moment i change ga_site_administrator (which is a custom role, with edit_users capability), the to ‘edit_users’, the grant roles button disappears.

    Also, another interesting thing – with my change applied – if I select 1 user and click on Grant Roles, I get URE: Insufficient Privileges. If I select 2 or more, It brings up the html for Granting Roles.

    Thanks,

    Shweta

Viewing 8 posts - 16 through 23 (of 23 total)
  • You must be logged in to reply to this topic.