• Resolved joenancym

    (@joenancym)


    I need to create a custom role with various capabilities in WordPress. I need to edit the function.php file of my theme. This is my code:

    /* Create Author Pro User Role */
    add_role( ‘author_pro’, // System name of the role. __( ‘Author Pro’ ), // Display name of the role.
    array( ‘read’ => true,
    ‘edit_posts’ => true,
    ‘publish_posts’ => true,
    ‘edit_published_posts’ => true,
    ‘edit_others_posts’ => true,
    ‘edit_pages’ => true,
    ‘edit_others_pages’ => true,
    ‘edit_private_pages’ => true,
    ‘edit_published_pages’ => true,
    ‘upload_files’ => true,
    ‘moderate_comments’=> true, // This user will be able to moderate the comments. ) );

    Problem is, the role is not able to edit pages created by others. What am I getting wrong?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I tried your role on my site and a user with that role is able to edit other’s pages. Someone with higher capability would have to approve the changes, but editing is possible with that set of capabilities.

    It’s possible other code or saved capabilities is contradicting your efforts. For example, it’s possible to revoke a specific capability on a user by user basis regardless of their assigned role. I suggest using a Roles and Capabilities plugin to examine what capabilities are in effect for a user with this role to see if there is any contradicting capability configurations. Such a plugin might be able to help you resolve any contradictions. Once this issue has been resolved you can deactivate and remove the plugin. You don’t necessarily need to keep it unless you find it useful for other purposes.

    The code you posted has been corrupted by the forum’s parser. I’m assuming you used proper syntax in your actual code. To avoid such corruption next time, please post any code in a code block intended for the purpose, or demarcate code with backticks.

    If your theme is subject to periodic updates it’s not a good idea to alter its functions.php file. Updates will wipe out your added code. Instead implement your code via a custom plugin or child theme.

    Thread Starter joenancym

    (@joenancym)

    Thank you @bcworkz for your response. This really helped a lot. I am not a big fun of plugins so your tip came in handy.
    I Will be sure to use a code block next time I post in the forum.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Roles & Capabilities’ is closed to new replies.