Custom Admin Column – Display Content Access Permissions

Members 3 posts 2 voices

  1. Hello team – I’m attempting to display the names of roles which have access to pages assigned to multiple member roles in the dashboard / page listing.

    Is there a shortcut to make this happen?
    It doesn’t seem this is a built in option with the Members plugin.

    What I’d like to accomplish:

    a) assign specific pages to one or more user roles, restricting content from users outside of these roles.

    b) easily see in the pages listing of the dashboard which roles are able to access each page.

    Here’s a screenshot – close but only showing the first role instead of the multiple roles:
    https://cl.ly/2z2s0S2L292h

    Thanks for any tips on getting content access columns in admin dashboard!

  2. I assume you’re referring to the Content Permissions feature. To get the roles for this, you need the members_get_post_roles() function. You’d use it like so:

    $roles = members_get_post_roles( $post_id );
    
    if ( $roles )
    	echo join( ', ', $roles );

    That’ll separate them with a comma.

  3. That’s perfect – makes sense to me!