Skip to:
Content

BuddyPress.org

Changeset 12926


Ignore:
Timestamp:
04/28/2021 11:52:01 PM (3 years ago)
Author:
dcavins
Message:

Member Invites: Filter "new member" activity item.

If a new user is accepting an invite, filter the
message to reflect that.

See #8139.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-activity.php

    r12851 r12926  
    5757 */
    5858function bp_members_format_activity_action_new_member( $action, $activity ) {
    59     $userlink = bp_core_get_userlink( $activity->user_id );
    60 
    61     /* translators: %s: user link */
    62     $action = sprintf( esc_html__( '%s became a registered member', 'buddypress' ), $userlink );
     59    $userlink         = bp_core_get_userlink( $activity->user_id );
     60    $inviter_userlink = false;
     61    $invite_id        = bp_get_user_meta( $activity->user_id, 'accepted_members_invitation', true );
     62
     63    if ( $invite_id ) {
     64        $invite = new BP_Invitation( (int) $invite_id );
     65
     66        if ( $invite->inviter_id ) {
     67            $inviter_userlink = bp_core_get_userlink( $invite->inviter_id );
     68        }
     69    }
     70
     71    if ( $inviter_userlink ) {
     72        $action = sprintf(
     73            /* translators: 1: new user link. 2: inviter user link. */
     74            esc_html__( '%1$s accepted an invitation from %2$s and became a registered member', 'buddypress' ),
     75            $userlink,
     76            $inviter_userlink
     77        );
     78    } else {
     79        /* translators: %s: user link */
     80        $action = sprintf( esc_html__( '%s became a registered member', 'buddypress' ), $userlink );
     81    }
    6382
    6483    // Legacy filter - pass $user_id instead of $activity.
     
    7190     *
    7291     * @since 2.2.0
    73      *
    74      * @param string $action   Static activity action.
    75      * @param object $activity Activity object.
    76      */
    77     return apply_filters( 'bp_members_format_activity_action_new_member', $action, $activity );
     92     * @since 8.0.0 Added $invite_id
     93     *
     94     * @param string $action    Static activity action.
     95     * @param object $activity  Activity object.
     96     * @param int    $invite_id The ID of the invite.
     97     */
     98    return apply_filters( 'bp_members_format_activity_action_new_member', $action, $activity, $invite_id );
    7899}
    79100
Note: See TracChangeset for help on using the changeset viewer.