Friends 1.x

Legacy documentation for Friends 1.x.

The Friends:Group_Add function is how your users will request to join groups or confirm group invitations. It also works for a Group owner to send out an invitation, or for confirming requests to join the group. It runs on similar principles as the Friends:Add function, but with a few more controls. You simply create links on other templates that link to a template with this code on it. Based on the group name or ID and the member ID in the URI, the Friends:Group_Add function will output a success/failure message, and it will take care of the rest. Additionally, notifications can be sent out to members for all actions.

To remove yourself from a Group, or to remove another user from your group, your link to this template would look exactly the same, except you would append a delete segment at the end of the URL.

{exp:friends:group_add} content {/exp:friends:group_add}

Parameters

The following parameters are available for use:

delete=

delete="yes"

By specifying the delete in the last segment of the URI, Friends:Group_Add will automatically know to delete the member from the group. However, the delete parameter is available to keep this function operating in delete mode in the event you have the dynamic parameter set to off. Default is no.

dynamic=

dynamic="off"

This parameter disables the Friends:Group_Form function from looking into the URI for member or group ID's.

friends_group_id=

friends_group_id="{segment_3}"

Friends:Group_Add will automatically know which group to account for based on the group segment in the URI. However, this parameter is available to pull the ID dynamically from the URI in the event you have the dynamic parameter set to off.

group_name=

group_name="{segment_3}"

Friends:Group_Add will automatically know which group to account for based on the group segment in the URI. However, this parameter is available to pull the group short_name dynamically from the URI in the event you have the dynamic parameter set to off.

member_id=

member_id="{segment_4}"

Friends:Group_Add will automatically know which member to account for based on the member segment in the URI. However, this parameter is available to pull the member ID dynamically from the URI in the event you have the dynamic parameter set to off.

notification_accept=

notification_accept="friends_notifications/group_accept"

This parameter controls which EE template to use to format a notification to the group owner when someone accepts his invitation to join a group.

notification_approve=

notification_approve="friends_notifications/group_approve"

This parameter controls which EE template to use to format a notification to the user who requested membership to a group when their request has been confirmed.

notification_invite=

notification_invite="friends_notifications/group_invite"

This parameter controls which EE template to use to format a notification to the user who is being invited to join a group.

notification_leave=

notification_leave="friends_notifications/group_leave"

This parameter controls which EE template to use to format a notification to the group owner when a user leaves their group.

notification_remove=

notification_remove="friends_notifications/group_remove"

This parameter controls which EE template to use to format a notification to the user when they are removed from a group by the group owner.

notification_request=

notification_request="friends_notifications/group_request"

This parameter controls which EE template to use to format a notification to the group owner when a user requests to join his group.

subject_accept=

subject_accept="{friends_user_screen_name} has accepted your invitation to join your group!"

This parameter outputs the subject line for the notification email to the group owner when someone accepts his invitation to join a group.

subject_approve=

subject_approve="You are now a member of the {friends_group_title} group!"

This parameter outputs the subject line for the notification email to the user who requested membership to a group when their request has been confirmed.

subject_invite=

subject_invite="{friends_owner_screen_name} would like you to join the {friends_group_title} group"

This parameter outputs the subject line for the notification email to the user who is being invited to join a group.

subject_leave=

subject_leave="{friends_user_screen_name} has left the {friends_group_title} group"

This parameter outputs the subject line for the notification email to the group owner when a user leaves their group.

subject_remove=

subject_remove="You have been removed from the {friends_group_title} group"

This parameter outputs the subject line for the notification email to the user when they are removed from a group by the group owner.

subject_request=

subject_request="{friends_user_screen_name} has requested to join the {friends_group_title} group"

This parameter outputs the subject line for the notification email to the group owner when a user requests to join his group.

Variables

The following variables are available for use:

friends_message

{friends_message}

This variable will output the success message or any errors upon loading the Friends:Group_Add template.

friends_owner_member_field

{friends_owner_member_field}

You can parse the screen_name, username, and member_id member fields for both the user and the group owner for use in the Notification Templates as well as the subject_ parameters. To parse these member fields for the group owner, prepend the variables with friends_owner_. To construct this variable, simply use friends_owner_ + member_field_name.

friends_owner_user_field

{friends_user_member_field}

You can parse the screen_name, username, and member_id member fields for both the user and the group owner for use in the Notification Templates as well as the subject_ parameters. To parse these member fields for the user, prepend the variables with friends_user_. To construct this variable, simply use friends_user_ + member_field_name.

Conditionals

The following conditionals are available for use:

failure

{if failure}Error!{/if}

This conditional shows its contents if the request action DOES NOT execute successfully.

success

{if success}Successful!{/if}

This conditional shows its contents if the request action executes successfully.

Examples

The following code should be a complete example for using this function, as well as using notifications:

{exp:friends:group_add
    notification_accept="friends_notifications/group_accept"
    notification_approve="friends_notifications/group_approve"
    notification_invite="friends_notifications/group_invite"
    notification_request="friends_notifications/group_request"
    subject_accept="{friends_user_screen_name} has accepted your invitation to join your group!"
    subject_approve="You are now a member of the {friends_group_title} group!"
    subject_invite="{friends_owner_screen_name} would like you to join the {friends_group_title} group"
    subject_request="{friends_user_screen_name} has requested to join the {friends_group_title} group"
}

    {if success}
        <h3>Successful!</h3>
    {/if}
    {if failure}
        <h3>Error!</h3>
    {/if}

    <p>{friends_message}</p>

{/exp:friends:group_add}

Requesting to join a group

If this template was located at friends/group_add, you would link to this page from another template like this:

  • http://www.yoursite.com/friends/group_add/group/GROUP_ID_OR_NAME/

For the group owner to approve the request, you would link to this page from another template or notificaton email like this:

  • http://www.yoursite.com/friends/group_add/group/GROUP_ID_OR_NAME/member/MEMBER_ID_OR_USERNAME/

For a user to leave a group, you would link to this page like this:

  • http://www.yoursite.com/friends/group_add/group/GROUP_ID_OR_NAME/delete/

Sending invitations as a Group Owner

If this template was located at friends/group_add, you would link to this page from another template like this:

  • http://www.yoursite.com/friends/group_add/group/GROUP_ID_OR_NAME/member/MEMBER_ID_OR_USERNAME/

For the user who receives the invitation, to accept the request, you would link to this page from another template or notificaton email like this:

  • http://www.yoursite.com/friends/group_add/group/GROUP_ID_OR_NAME/

For a group owner to remove a user from the group, you would link to this page like this:

  • http://www.yoursite.com/friends/group_add/group/GROUP_ID_OR_NAME/member/MEMBER_ID_OR_USERNAME/delete/

Notification Templates

For your notification templates, you use regular EE templates, and just add code like this:

User requests to join a group ("friends_notifications/group_request")

Hello {friends_owner_screen_name}!

{friends_user_screen_name} would like to join
the {friends_group_title} group.

Click the link below to accept this request to join your group:
{path='friends/group_add'}/group/{friends_group_id}/member/{friends_user_member_id}/

User accepts invitation to join group ("friends_notifications/group_accept")

Hello {friends_owner_screen_name}!

{friends_user_screen_name} has accepted your request
and joined the {friends_group_title} group!

Click the link below to view their profile:
{path='friends/profile'}/{friends_user_member_id}/

User leaves group ("friends_notifications/group_leave")

Hello {friends_owner_screen_name}!

{friends_user_screen_name} has just left the
{friends_group_title} group.

Click the link below to view their profile:
{path='friends/profile'}/{friends_user_member_id}/

Group Owner invites user to join his group ("friends_notifications/group_invite")

Hello {friends_user_screen_name}!

You have been invited to join the {friends_group_title} group.

Click the link below to accept this request and join the group:
{path='friends/group_add'}/group/{friends_group_id}/

Group Owner approves of user request to join group ("friends_notifications/group_approve")

Hello {friends_user_screen_name}!

You request to join the {friends_group_title} group
has been accepted!

Click the link below to view the group:
{path='friends/group_info'}/{friends_group_id}/

Group Owner removes user from group ("friends_notifications/group_remove")

Hello {friends_user_screen_name}!

You have been removed from the {friends_group_title} group.

Click the link below to view the group:
{path='friends/group_info'}/{friends_group_id}/