Skip to:
Content
Pages
Categories
Search
Top
Bottom

Invite anyone and user role


  • halloy
    Participant

    @halloy

    Hi ! I installed this plugin to let members wich have created their own group to invite friends (not already members) by mail.
    It works correctly but by default the invited member receive the basic user role Subscriber.
    I needed to create custom user roles wit the plugin User Role.
    I wish to associate these invited with a particular role (for example invited_members)
    How can I do ?

    Thanks a lot !

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

  • Venutius
    Moderator

    @venutius

    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' );
        }
    }

    halloy
    Participant

    @halloy

    Thank you very much for your reply. The plugin allows members to invite by email friends wich are not yet subscriber (friends in the real life not BP friends). So, I need to associated a custom user role at these new members for other functionnalities in the website. I’ll try your code.

    I have not yet tested the plugin to the end to see if the guest is only associated with the group that invites him or if he then has access to all groups.


    Venutius
    Moderator

    @venutius

    Yes that would be a lot more complex I think, you’d need to create some way of storing the invited email addresses and check new signups for that email address. I think you’d need to create a plugin for that, it’s quite a bit more than a few lines in a code snippet.


    halloy
    Participant

    @halloy

    Hello, I tried your code with adding it in functions.php of the theme and replacing in add_role ‘invited_members’ by the name of my custom role. But it doens’t work, the new invited stays subscriber.

    Is it because is not an invite sent to a group but by mail ?

    What is the variable $inviter ? the member wich send the invite or this one wich receive the invitation by mail ?

    I don’t find the variable $invited_users in by-mail.php nor in your functions.php. Is it a Buddypress variable ?

    I see in the file functions.php of your module in the $defaults_array : ‘minimum_role’ => ‘subscriber’.
    What is it ? Is it the minimum role of member to be able to send an invitation ?

    And an other question : when the new user has followed all the steps and go to the profile of wich had invited him, he cannot write on his wall or add medias, just read. Is it normal ?

    Thanks a lot for your help !
    Otherwhise, your plugin works fine !


    Venutius
    Moderator

    @venutius

    Hi there, you seem to be asking me questions about code I’ve not written, I’m not the author of invite anyone. You are the secod person asking to be able to identify invites users from Invite Anyone. I suggest you raise a feature request on that plugin for this. Then the external invites could also be taken into account.


    halloy
    Participant

    @halloy

    Hi Venutius, thanks for your reply and sorry ! I don’t know why I believed you’re the author 😉


    Venutius
    Moderator

    @venutius

    No worries, you had me confused there.

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