Support » Plugin: Multiple Roles » Plugin Conflict with wpDirAuth

  • Hi, I’ve been adding Multiple Roles to our sites on multisite installations. I’m using version 1.0 on WordPress 4.2.2.

    I ran into an unexpected issue this week. We use LDAP authentication via the wpDirAuth plugin, and when we add directory-authenticated users through their interface, it indicates that the user is successfully added, but the new user doesn’t appear in the Users list.

    In tracing back what’s being added to the wp_users and wp_usermeta tables, I found that no role is being assigned to the new user — only an empty array.

    Experimenting with it further, I found that by commenting out this line in multiple-roles.php:

    add_action(‘user_register’, array( $checklist, ‘process_checklist’));

    that adding the directory-authenticated user now works.

    My best guess is that the logic in the function process_checklist($user_id) was intended to return in a context where $_POST[‘md_multiple_roles_nonce’] is unset. Instead, it seems to be setting $new_roles to an empty array and applying that to the newly-created user.

    Can you check this out and see if it’s possible to adjust the logic so it will work in such cases? Anything you can do would be appreciated.

    https://wordpress.org/plugins/multiple-roles/

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you look at the MDMR_Checklist_Controller class, process_checklist method, line 69, if $_POST[‘md_multiple_roles’] isn’t set, then $new_roles is set to an empty array. Since you are adding and assigning a role initially through wpDirAuth, $_POST[‘md_multiple_roles’] isn’t going to be set (since wpDirAuth doesn’t have any knowledge of multiple roles plugin), and therefore multiple roles is removing the roles originally set by wpDirAuth.

    @seventhsteel, what you’ll probably need to do is in process_checklist() verify your nonce is set first, and if not return so that if another plugin is registering the user, you aren’t inadvertently wiping out the roles it has set.

    public function process_checklist( $user_id ) {
    		if(isset($_POST['md_multiple_roles_nonce'])
    		    && wp_verify_nonce( $_POST['md_multiple_roles_nonce'], 'update-md-multiple-roles' )
    			&& this->model->can_update_roles()
    			&& isset( $_POST['md_multiple_roles'] )
    		) {
    			$this->model->update_roles( $user_id, $_POST['md_multiple_roles'] );
    		}
    
    	}

    Thanks, gilzow, for confirming what I was seeing and the possible solution.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plugin Conflict with wpDirAuth’ is closed to new replies.