• Resolved tristanmason

    (@tristanmason)


    Our users are assigned multiple custom roles to gain access to different areas of the site. For example, a user might be a Subscriber, but also be assigned the custom roles Maintenance and Security. In Content Control, some users assigned the Maintenance role still cannot access content that should be visible to them.

    I suspect this might be because our users have multiple roles. Will Content Control check all of the user’s roles before redirecting them to login?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter tristanmason

    (@tristanmason)

    After looking through the code, it looks like Content Control should be looping through all the roles and only excluding the user if there are no valid roles that can access the content:

    // Checks all roles, should not exclude if any are active.
    $valid_role = false;
    
    foreach ( $roles as $role ) {
    	if ( current_user_can( $role ) ) {
    		$valid_role = true;
    		break;
    	}
    }

    So now I’m stumped as to why some of our users with valid roles are still being redirected to login when trying to access content. We are using the Members plugin to create and assign the roles.

    • This reply was modified 1 year, 3 months ago by tristanmason.
    Plugin Author Daniel Iser

    (@danieliser)

    I assume your confirming those roles show up as available to select.

    The only thing that comes to mind is that they register roles later than expected.

    You might try forcing those roles to be in the list of roles earlier using this filter: https://github.com/code-atlantic/content-control/blob/master/classes/Roles.php#L23C29-L23C45

    Plugin Support Kim L

    (@kimmyx)

    Hi there,

    I’m going to mark this as resolved as we haven’t heard from you in a while.

    Feel free to create a new thread if you have other questions.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multiple roles per user’ is closed to new replies.