WordPress.org

Ready to get started?Download WordPress

Forums

User Role Editor
sub-page capability (20 posts)

  1. Zeb
    Member
    Posted 3 years ago #

    Two questions:

    1. How can I create capability for sub-categories and sub-pages. Is it enough just to add something like the following or I need to do more? Were can I find a list for this kind of meta.

    publish_sub_page
    edit_sub_page
    edit_published_sub_page
    delete_sub_page

    2. There is a feature in the screen shots that shows how to copy existing capabilities to a new role. there is no such window in the latest version of the pluging.

    Appreciate your concern.

  2. Vladimir Garagulya
    Member
    Plugin Author

    Posted 3 years ago #

    1. It is not enough just create capability. All capabilities are checked by WordPress in its core code directly, like this

    if (!$current_user_can('edit_post') {
      echo 'you have not permission to edit posts';
      return;
    }

    Thus, if you create new capability it is your responsibility to check if user has it (in your theme or plugin code)

    2. What screen-shot number do you write about? There is no functionality to copy one role content (capabilities) to another in URE plugin for this moment. If it could be useful, I can consider to add such function.

  3. Zeb
    Member
    Posted 3 years ago #

    Thanks for the reply.

    1. Is this code you mentioned all I need to create a new capability or there is a How to instructions to follow creating a new role? Of course for users like me who are not very skilled can be a challenge creating new roles.

    2. Ok, it seems I looked at Capability Manager's copy feature (screenshot 2) instead. But the feature could be useful if a user intends to choose an existing capability/role, copy to a new one with a new name and edit it afterward to minimize mistakes. Otherwise, a user has to write down everything for the base role and fill out the check boxes.

    3. Possible bug! When I deselect comment mediation, a user still can moderate! Do I have to do anything else?

    Appreciate your concern.

  4. Vladimir Garagulya
    Member
    Plugin Author

    Posted 3 years ago #

    I made a typo in code snippet above: 'edit_posts' should be there instead of 'edit_post'.
    1. Creating new role is not so difficult if you intend to use just standard WordPress capabilities. You can modify existing role or create new one and fill it with capabilities according your needs. Just make and see what will be.
    If you need to realize something new, then you need to find the right place where to insert your capability checking code. Modifying core WordPress files is not the good practice as you will lose your changes every time you install next WordPress update. There are so called hooks (filters and actions) in WordPress, which allows to add new functionality to core WordPress code without changing its core code.
    I suppose that it is difficult task to realize separate capabilities checking for subpages as there is no separate type for that. Subpage has the same type as the page, that is 'page'. 'subpage' is the sign of hierarchy structure only. May be I'm wrong, let me know if such :).
    2. Thanks for the valuable idea I will add this feature to the next update.
    3. Could you show me screenshot of the role you modified or send its capabilities list in order I can check at test site?

  5. Zeb
    Member
    Posted 3 years ago #

    Thanks again for your feedback.

    1. Sub-page publish capability: A user could have capability to publish/edit sub-pages, if and only if, he has selected a parent page he already has access to. Otherwise, he would be denied to publish/edit the page. I think, this way could work and it shouldn't be necessary to hard code WP files.

    2. Thanks for your plan.
    3. I actually just selected same capabilities as author/editor for a new role and unchecked Comment Moderation. I tested and the result was that Moderation did not applied. Consequently, when logged in, I could see and moderate regardless of role (subscriber is exception)!
    (I'll try to send you screenshot by e-mail)

    I tested the roles for s2Member different levels. Default capabilities are set to subscriber for each level.

    Appreciate it!

  6. Zeb
    Member
    Posted 3 years ago #

    I tried to find out how I can send you the screenshot without luck. I could not find any email at your site either. A contact form at your site does not allow file uploads.
    Please let me know how I can send you the screenshot if needed.

    Thanks in advance.

  7. Vladimir Garagulya
    Member
    Plugin Author

    Posted 3 years ago #

    You are welcome to send me the screenshot.
    I don't expose my email to the Internet resources to not catch spam.
    You could send me a message via shinephp.com contact form and get my answer to your email. My email address consists of my name 'vladimir' and my domain 'shinephp.com'.

  8. Zeb
    Member
    Posted 3 years ago #

    Thanks! I did sent it yesterday. Please let me know about the outcome :)

  9. Vladimir Garagulya
    Member
    Plugin Author

    Posted 3 years ago #

    Excuse me for delay with reply.
    It seems that WordPress allows moderate comments for post not only owner of 'moderate_comments' capability, but to the user who can edit that post, that is 'editor' and 'administrator' are in the list of persons with such moderation power.
    Quote from line 42 of wp-admin/edit-comments.php:

    foreach ( $comment_ids as $comment_id ) { // Check the permissions on each
    	if ( !current_user_can( 'edit_comment', $comment_id ) )
    		continue;
    
    	switch ( $doaction ) {
    		case 'approve' :

    and 'edit_comment' is mapped to 'edit_posts' at the
    wp-admin/includes/capabilities.php - map_meta_cap(), look to lines 954-959:

    case 'edit_comment':
    	$comment = get_comment( $args[0] );
    	$post = get_post( $comment->comment_post_ID );
    	$post_type_object = get_post_type_object( $post->post_type );
    
    	$caps = map_meta_cap( $post_type_object->cap->edit_post, $user_id, $post->ID );
  10. Zeb
    Member
    Posted 3 years ago #

    Thank you Vladimir,

    So just to summarize it, you mean that it's not possible to restrict moderation for a user who has capability to edit a post?

    Is there any workaround to restrict moderation capability anyway?

  11. Vladimir Garagulya
    Member
    Plugin Author

    Posted 3 years ago #

    The simplest way is edit /wp-admin/edit-comments.php at line 11:

    if ( !current_user_can('edit_posts') )
    	wp_die(__('Cheatin’ uh?'));

    and change 'edit_posts' to 'moderate_comments'. This way you can prohibit users without 'moderate_comments' capability even open comments list.
    The negative side is that you should hold this modification in your head and repeat this step after every WordPress update install.

    I tried to find how to achieve this via WordPress hooks, but with a half success only. It is possible to hide user interface part: bulk actions, moderation links from user without moderate_comments permission, but this functionality will be still available through direct link call if you type it in the browser.
    It seems that there is no any hook we can use to block moderation action this way without editing core WordPress files :(.

  12. Vladimir Garagulya
    Member
    Plugin Author

    Posted 3 years ago #

    To get more details on subject read this post
    http://www.shinephp.com/limit-comments-moderation/

  13. Zeb
    Member
    Posted 3 years ago #

    Thank you very much for your reply.

    However, your solution seems logical. I assume that it should hide the moderation buttons/links when using your plugin with unchecked Moderation Capability. (Of course, I'm aware of modifications to be done in functions.php, according to your article).

    Please let me see if I can make it work.

    Thanks again!
    Cheers

  14. Zeb
    Member
    Posted 3 years ago #

    Just an updated question!

    According to the user level capabilities, moderation is not available for user levels 0-3. If user Levels were finally deprecated in WordPress 3.0, how does this work in your plugin? Are these levels activated in the plugin or just out-dated and not applicable?

  15. Vladimir Garagulya
    Member
    Plugin Author

    Posted 3 years ago #

    Read a note at the begin of the same page:
    "Note: User Levels were introduced in WordPress 1.5, they were replaced by Roles and Capabilities in WordPress 2.0, and were finally deprecated in WordPress 3.0".

    Thus, user levels were deprecated since WordPress 3.0 and we can ignore them if we don't use some out-dated plugin or theme.

  16. Zeb
    Member
    Posted 3 years ago #

    Of course, I have read that. Just wondered if they were functional through the plugin because the check boxes are selectable.
    Thanks

  17. Vladimir Garagulya
    Member
    Plugin Author

    Posted 3 years ago #

    I didn't block them for backward compatibility purposes. As WordPress itself still stores user levels in roles data we should see what we have there, and be capable edit any data without exclusion.
    From other side, option, e.g. "turn off and hide deprecated user levels" could be useful for somebody. What do you think?

  18. Zeb
    Member
    Posted 3 years ago #

    Absolutely, because it seems that it creates doubts about the plugin and some users think that it's some kind of problem with the plugin itself. See this thread.

    Turning on/off is a very good idea if you could place it on the menu beside the "show capability" check box where nobody could miss it. Just one more tiny thing... If you could place a "?" that would display a tool-tip on hover with that deprecated info you mentioned, would be very helpful.

    cheers

  19. Vladimir Garagulya
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks for idea. I will include this feature to the next version.

  20. Zeb
    Member
    Posted 3 years ago #

    Great, then we'll see that feature soon ;)

    cheers

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic