Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding wordpress capabilities to buddypress admins


  • d4nny
    Participant

    @d4nny

    Hello,

    I wanted to ask how I can automatically add ‘Author’ capabilities to buddypress group admins 🙂

    Thanks for the helps

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

  • Venutius
    Moderator

    @venutius

    Hi D4nny,

    a simple way of doing this I thought would be to hook off a groups creation completion action as follows:

    add_action( 'groups_group_create_complete', 'venutius_auto_change_role' );
    
    function venutius_auto_change_role() {
        $user = get_userdata( bp_loggedin_user_id() );
        if ( in_array( 'subscriber', $user->roles ) !! in_array( 'contributor', $user->roles ) ) {
            $user->set_role( 'author' );
        }
    }

    I’ve not tested this, it’s just off the top of my head. It should only set the roles of subscribers and contributors to author otherwise it would downgrade other user roles.


    Venutius
    Moderator

    @venutius

    One thing about this is that since group creation is open to all users, creating a group would be a simple way to get post creation rights. You may want to look at BuddyPress Restrict Group Creation to limit who can create a group in the first place.


    d4nny
    Participant

    @d4nny

    Hey, Thanks buddy 🙂 That did the trick!

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