Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #7184
    UserRole_Klima
    Participant

    I have a role that grants all permissions to do with events. This roles should now be granted editing permissions for specific posts (by ID). Using the “Post Edit Access” window and supplying it with the respective post ID under “with post ID (comma separated)” eliminates the role’s permissions, seemingly joining the permissions by intersection instead of union.
    Help is much appreciated.

    #7186
    Vladimir
    Keymaster

    Right, “Edit access” add-on restrict all post types at once, if find at least one restriction criteria. If you need to exclude events from edit restrictions you can use custom filter ure_restrict_edit_post_type.

    #7189
    UserRole_Klima
    Participant

    Thanks for the reply. Now, using your code example, how do I allow the specified role (‘editor’ in your example) to only edit posts of a specific ID?

    #7190
    Vladimir
    Keymaster

    You don’t need a code for this. Open ‘Users->User Role Editor’, select role, click ‘Posts Edit’ insert the list of posts ID into the ‘with post ID (comma separated)’ field.
    Or, you can make it individually for selected users via user profile.

    #7191
    UserRole_Klima
    Participant

    I can’t use ‘Posts Edit’ as it will restrict the role’s permissions to only the there-specified IDs. What I need is to keep all permissions of the role PLUS permissions for some post IDs.

    #7192
    Vladimir
    Keymaster

    If you setup the code for custom filter ure_restrict_edit_post_type (I gave the link above) to exclude events from the edit restrictions, user will have access to all events without restrictions. It does not depend from post ID list in the edit restrictions form.
    You just need:
    1) replace ‘editor’ with your own role ID, let it be ‘role_a’;
    2) replace ‘post’ with valid custom post type for events, let it be for this example: ‘event’.
    So instead of

    
      if ( in_array( 'editor', $user->roles ) ) {
          if ( $post_type==='post' ) {
    	   $restrict_it = false;
          }
      }
    

    your code will have

    
      if ( in_array( 'role_a', $user->roles ) ) {
          if ( $post_type==='event' ) {
    	   $restrict_it = false;
          }
      }
    

    In assumption that you made all correctly, you can input post ID list after that and check that all events are still available for the role.

    #7194
    UserRole_Klima
    Participant

    Now I got it, thank you.
    Just as a feedback note, the permission system would be more intuitive and, frankly, more useful, if the different permissions were ORed instead of ANDed.

    Thank you again for your fast help.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.