Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Invite anyone and user role

@venutius

Moderator

I’m a bit uncertain as to the use case here: joining a group does not change the members role on the site, they started off as subscriber and they remained subscriber after joining. however you could acheive what you want by using the groups_send_invites action.

So something like:

add_action( 'groups_send_invites', 'venutius_invited_users_role', 10, 3);

function venutius_invited_users_role( $group_id, $invited_users, $user_id ) {
    foreach ( $invited_users as $invited_user ) {
        $user = get_userdata( $invited_user );
        $user->add_role( 'invited_members' );
    }
}
Skip to toolbar