Skip to:
Content
Pages
Categories
Search
Top
Bottom

Assigning Moderator Role in addition to Author and Editor WordPress roles?

  • Hi! I have bbPress as a plugin on WordPress and BuddyPress powered website. On my WordPress I have users set up as Editors, Authors, and Contributors.

    For the forum, I’d like editors and authors to also have forum moderation abilities in addition to their preexisting WordPress capabilities. I don’t want them to *just* be moderators.

    Is this possible? I looked at the roles documentation, but I can’t figure it out.

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)

  • Lynq
    Participant

    @lynq

    You could add a new role for your site: https://codex.wordpress.org/Function_Reference/add_role


    mindsink-web
    Member

    @mindsink-web

    Hope this helps:

    Add this to the bottom of your theme’s functions.php file. For example wp-content/themes/mycurrenttheme/functions.php

    function add_my_new_theme_caps() {

    $role = get_role( ‘editor’ ); // gets the editor role

    $role->add_cap( ‘publish_forums’ );

    $role->add_cap( ‘edit_forums’ );

    $role->add_cap( ‘delete_forums’ );

    $role->add_cap( ‘delete_others_forums’ );

    $role->add_cap( ‘read_private_forums’ );

    $role->add_cap( ‘publish_topics’ );

    $role->add_cap( ‘edit_topics’ );

    $role->add_cap( ‘edit_others_topics’ );

    $role->add_cap( ‘delete_topics’ );

    $role->add_cap( ‘delete_others_topics’ );

    $role->add_cap( ‘publish_replies’ );

    $role->add_cap( ‘edit_replies’ );

    $role->add_cap( ‘edit_others_replies’ );

    $role->add_cap( ‘read_private_topics’ );

    $role->add_cap( ‘delete_replies’ );

    $role->add_cap( ‘delete_others_replies’ );

    $role->add_cap( ‘manage_topic_tags’ );

    $role->add_cap( ‘edit_topic_tags’ );

    $role->add_cap( ‘delete_topic_tags’ );

    $role->add_cap( ‘read_private_replies’ );

    $role->add_cap( ‘assign_topic_tags’ );

    $role->add_cap( ‘moderate’ );

    $role->add_cap( ‘throttle’ );

    $role->add_cap( ‘view_trash’ );

    }

    add_action( ‘admin_init’, ‘add_my_new_theme_caps’);

    function add_my_new_theme_caps2() {

    $role = get_role( ‘author’ ); // gets the editor role

    $role->add_cap( ‘publish_forums’ );

    $role->add_cap( ‘edit_forums’ );

    $role->add_cap( ‘delete_forums’ );

    $role->add_cap( ‘delete_others_forums’ );

    $role->add_cap( ‘read_private_forums’ );

    $role->add_cap( ‘publish_topics’ );

    $role->add_cap( ‘edit_topics’ );

    $role->add_cap( ‘edit_others_topics’ );

    $role->add_cap( ‘delete_topics’ );

    $role->add_cap( ‘delete_others_topics’ );

    $role->add_cap( ‘publish_replies’ );

    $role->add_cap( ‘edit_replies’ );

    $role->add_cap( ‘edit_others_replies’ );

    $role->add_cap( ‘read_private_topics’ );

    $role->add_cap( ‘delete_replies’ );

    $role->add_cap( ‘delete_others_replies’ );

    $role->add_cap( ‘manage_topic_tags’ );

    $role->add_cap( ‘edit_topic_tags’ );

    $role->add_cap( ‘delete_topic_tags’ );

    $role->add_cap( ‘read_private_replies’ );

    $role->add_cap( ‘assign_topic_tags’ );

    $role->add_cap( ‘moderate’ );

    $role->add_cap( ‘throttle’ );

    $role->add_cap( ‘view_trash’ );

    }

    add_action( ‘admin_init’, ‘add_my_new_theme_caps2’);

    Mindsink, thank you so much! That’s perfect!


    pxforti
    Participant

    @pxforti

    Awesome. Thanks for posting that. Worked for me.


    nyks-barton
    Participant

    @nyks-barton

    Looks perfect. As I only want to give Editors the forum-moderation, I think, I only have to add the first part of the code.

    A small hint: as I understand the code, there the code-comment in the 2nd part i incorrect:s
    $role = get_role( ‘author’ ); // gets the editor role
    It gets the author-role, isnt it?


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    I’d hold off, as bbPress 2.2 will address this specifically.


    nyks-barton
    Participant

    @nyks-barton

    Hi Keymaster,

    can you give us a rough estimate, when 2.2 will be released?

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