[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-groups/ -> bp-groups-notifications.php (source)

   1  <?php
   2  /**
   3   * BuddyPress Groups Notification Functions.
   4   *
   5   * These functions handle the recording, deleting and formatting of notifications
   6   * for the user and for this specific component.
   7   *
   8   * @package BuddyPress
   9   * @subpackage GroupsActivity
  10   * @since 1.0.0
  11   */
  12  
  13  // Exit if accessed directly.
  14  defined( 'ABSPATH' ) || exit;
  15  
  16  /** Emails ********************************************************************/
  17  
  18  /**
  19   * Notify all group members when a group is updated.
  20   *
  21   * @since 1.0.0
  22   *
  23   * @param int                  $group_id  ID of the group.
  24   * @param BP_Groups_Group|null $old_group Group before new details were saved.
  25   */
  26  function groups_notification_group_updated( $group_id = 0, $old_group = null ) {
  27      $group = groups_get_group( $group_id );
  28  
  29      if ( $old_group instanceof BP_Groups_Group ) {
  30          $changed = array();
  31  
  32          if ( $group->name !== $old_group->name ) {
  33              $changed[] = sprintf(
  34                  /* translators: 1: the old group name. 2: the new group name. */
  35                  _x( '* Name changed from "%1$s" to "%2$s".', 'Group update email text', 'buddypress' ),
  36                  esc_html( $old_group->name ),
  37                  esc_html( $group->name )
  38              );
  39          }
  40  
  41          if ( $group->description !== $old_group->description ) {
  42              $changed[] = sprintf(
  43                  /* translators: 1: the old group description. 2: the new group description. */
  44                  _x( '* Description changed from "%1$s" to "%2$s".', 'Group update email text', 'buddypress' ),
  45                  esc_html( $old_group->description ),
  46                  esc_html( $group->description )
  47              );
  48          }
  49  
  50          if ( $group->slug !== $old_group->slug ) {
  51              $changed[] = sprintf(
  52                  /* translators: 1: the old group permalink. 2: the new group permalink. */
  53                  _x( '* Permalink changed from "%1$s" to "%2$s".', 'Group update email text', 'buddypress' ),
  54                  esc_url( bp_get_group_permalink( $old_group ) ),
  55                  esc_url( bp_get_group_permalink( $group ) )
  56              );
  57          }
  58      }
  59  
  60      /**
  61       * Filters the bullet points listing updated items in the email notification after a group is updated.
  62       *
  63       * @since 2.2.0
  64       *
  65       * @param array $changed Array of bullet points.
  66       */
  67      $changed = apply_filters( 'groups_notification_group_update_updated_items', $changed );
  68  
  69      $changed_text = '';
  70      if ( ! empty( $changed ) ) {
  71          $changed_text = implode( "\n", $changed );
  72      }
  73  
  74      $user_ids = BP_Groups_Member::get_group_member_ids( $group->id );
  75      foreach ( (array) $user_ids as $user_id ) {
  76  
  77          // Continue if member opted out of receiving this email.
  78          if ( 'no' === bp_get_user_meta( $user_id, 'notification_groups_group_updated', true ) ) {
  79              continue;
  80          }
  81  
  82          $unsubscribe_args = array(
  83              'user_id'           => $user_id,
  84              'notification_type' => 'groups-details-updated',
  85          );
  86  
  87          $args = array(
  88              'tokens' => array(
  89                  'changed_text' => $changed_text,
  90                  'group'        => $group,
  91                  'group.id'     => $group_id,
  92                  'group.url'    => esc_url( bp_get_group_permalink( $group ) ),
  93                  'group.name'   => $group->name,
  94                  'unsubscribe'  => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),
  95              ),
  96          );
  97          bp_send_email( 'groups-details-updated', (int) $user_id, $args );
  98      }
  99  
 100      /**
 101       * Fires after the notification is sent that a group has been updated.
 102       *
 103       * See https://buddypress.trac.wordpress.org/ticket/3644 for blank message parameter.
 104       *
 105       * @since 1.5.0
 106       * @since 2.5.0 $subject has been unset and is deprecated.
 107       *
 108       * @param array  $user_ids Array of user IDs to notify about the update.
 109       * @param string $subject  Deprecated in 2.5; now an empty string.
 110       * @param string $value    Empty string preventing PHP error.
 111       * @param int    $group_id ID of the group that was updated.
 112       */
 113      do_action( 'bp_groups_sent_updated_email', $user_ids, '', '', $group_id );
 114  }
 115  
 116  /**
 117   * Notify group admin about new membership request.
 118   *
 119   * @since 1.0.0
 120   *
 121   * @param int $requesting_user_id ID of the user requesting group membership.
 122   * @param int $admin_id           ID of the group admin.
 123   * @param int $group_id           ID of the group.
 124   * @param int $membership_id      ID of the group membership object.
 125   */
 126  function groups_notification_new_membership_request( $requesting_user_id = 0, $admin_id = 0, $group_id = 0, $membership_id = 0 ) {
 127  
 128      // Trigger a BuddyPress Notification.
 129      if ( bp_is_active( 'notifications' ) ) {
 130          bp_notifications_add_notification( array(
 131              'user_id'           => $admin_id,
 132              'item_id'           => $group_id,
 133              'secondary_item_id' => $requesting_user_id,
 134              'component_name'    => buddypress()->groups->id,
 135              'component_action'  => 'new_membership_request',
 136          ) );
 137      }
 138  
 139      // Bail if member opted out of receiving this email.
 140      if ( 'no' === bp_get_user_meta( $admin_id, 'notification_groups_membership_request', true ) ) {
 141          return;
 142      }
 143  
 144      $unsubscribe_args = array(
 145          'user_id'           => $admin_id,
 146          'notification_type' => 'groups-membership-request',
 147      );
 148  
 149      $request_message = '';
 150      $requests = groups_get_requests( $args = array(
 151          'user_id'    => $requesting_user_id,
 152          'item_id'    => $group_id,
 153      ) );
 154      if ( $requests ) {
 155          $request_message = current( $requests )->content;
 156      }
 157  
 158      $group = groups_get_group( $group_id );
 159      $args  = array(
 160          'tokens' => array(
 161              'admin.id'             => $admin_id,
 162              'group'                => $group,
 163              'group.name'           => $group->name,
 164              'group.id'             => $group_id,
 165              'group-requests.url'   => esc_url( bp_get_group_permalink( $group ) . 'admin/membership-requests' ),
 166              'profile.url'          => esc_url( bp_core_get_user_domain( $requesting_user_id ) ),
 167              'requesting-user.id'   => $requesting_user_id,
 168              'requesting-user.name' => bp_core_get_user_displayname( $requesting_user_id ),
 169              'request.message'      => $request_message,
 170              'unsubscribe'          => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),
 171          ),
 172      );
 173      bp_send_email( 'groups-membership-request', (int) $admin_id, $args );
 174  }
 175  
 176  /**
 177   * Notify member about their group membership request.
 178   *
 179   * @since 1.0.0
 180   *
 181   * @param int  $requesting_user_id ID of the user requesting group membership.
 182   * @param int  $group_id           ID of the group.
 183   * @param bool $accepted           Optional. Whether the membership request was accepted.
 184   *                                 Default: true.
 185   */
 186  function groups_notification_membership_request_completed( $requesting_user_id = 0, $group_id = 0, $accepted = true ) {
 187  
 188      // Trigger a BuddyPress Notification.
 189      if ( bp_is_active( 'notifications' ) ) {
 190  
 191          // What type of acknowledgement.
 192          $type = ! empty( $accepted ) ? 'membership_request_accepted' : 'membership_request_rejected';
 193  
 194          bp_notifications_add_notification( array(
 195              'user_id'           => $requesting_user_id,
 196              'item_id'           => $group_id,
 197              'component_name'    => buddypress()->groups->id,
 198              'component_action'  => $type,
 199          ) );
 200      }
 201  
 202      // Bail if member opted out of receiving this email.
 203      if ( 'no' === bp_get_user_meta( $requesting_user_id, 'notification_membership_request_completed', true ) ) {
 204          return;
 205      }
 206  
 207      $group = groups_get_group( $group_id );
 208      $args  = array(
 209          'tokens' => array(
 210              'group'              => $group,
 211              'group.id'           => $group_id,
 212              'group.name'         => $group->name,
 213              'group.url'          => esc_url( bp_get_group_permalink( $group ) ),
 214              'requesting-user.id' => $requesting_user_id,
 215          ),
 216      );
 217  
 218      if ( ! empty( $accepted ) ) {
 219  
 220          $unsubscribe_args = array(
 221              'user_id'           => $requesting_user_id,
 222              'notification_type' => 'groups-membership-request-accepted',
 223          );
 224  
 225          $args['tokens']['unsubscribe'] = esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) );
 226  
 227          bp_send_email( 'groups-membership-request-accepted', (int) $requesting_user_id, $args );
 228  
 229      } else {
 230  
 231          $unsubscribe_args = array(
 232              'user_id'           => $requesting_user_id,
 233              'notification_type' => 'groups-membership-request-rejected',
 234          );
 235  
 236          $args['tokens']['unsubscribe'] = esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) );
 237  
 238          bp_send_email( 'groups-membership-request-rejected', (int) $requesting_user_id, $args );
 239      }
 240  }
 241  add_action( 'groups_membership_accepted', 'groups_notification_membership_request_completed', 10, 3 );
 242  add_action( 'groups_membership_rejected', 'groups_notification_membership_request_completed', 10, 3 );
 243  
 244  /**
 245   * Notify group member they have been promoted.
 246   *
 247   * @since 1.0.0
 248   *
 249   * @param int $user_id  ID of the user.
 250   * @param int $group_id ID of the group.
 251   */
 252  function groups_notification_promoted_member( $user_id = 0, $group_id = 0 ) {
 253  
 254      // What type of promotion is this?
 255      if ( groups_is_user_admin( $user_id, $group_id ) ) {
 256          $promoted_to = __( 'an administrator', 'buddypress' );
 257          $type        = 'member_promoted_to_admin';
 258      } else {
 259          $promoted_to = __( 'a moderator', 'buddypress' );
 260          $type        = 'member_promoted_to_mod';
 261      }
 262  
 263      // Trigger a BuddyPress Notification.
 264      if ( bp_is_active( 'notifications' ) ) {
 265          bp_notifications_add_notification( array(
 266              'user_id'           => $user_id,
 267              'item_id'           => $group_id,
 268              'component_name'    => buddypress()->groups->id,
 269              'component_action'  => $type,
 270          ) );
 271      }
 272  
 273      // Bail if admin opted out of receiving this email.
 274      if ( 'no' === bp_get_user_meta( $user_id, 'notification_groups_admin_promotion', true ) ) {
 275          return;
 276      }
 277  
 278      $unsubscribe_args = array(
 279          'user_id'           => $user_id,
 280          'notification_type' => 'groups-member-promoted',
 281      );
 282  
 283      $group = groups_get_group( $group_id );
 284      $args  = array(
 285          'tokens' => array(
 286              'group'       => $group,
 287              'group.id'    => $group_id,
 288              'group.url'   => esc_url( bp_get_group_permalink( $group ) ),
 289              'group.name'  => $group->name,
 290              'promoted_to' => $promoted_to,
 291              'user.id'     => $user_id,
 292              'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),
 293          ),
 294      );
 295      bp_send_email( 'groups-member-promoted', (int) $user_id, $args );
 296  }
 297  add_action( 'groups_promoted_member', 'groups_notification_promoted_member', 10, 2 );
 298  
 299  /**
 300   * Notify a member they have been invited to a group.
 301   *
 302   * @since 1.0.0
 303   *
 304   * @param BP_Groups_Group      $group           Group object.
 305   * @param BP_Groups_Member|int $member          Member object or invited_user_id.
 306   * @param int                  $inviter_user_id ID of the user who sent the invite.
 307   */
 308  function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) {
 309  
 310      // @todo $inviter_ud may be used for caching, test without it
 311      $inviter_ud      = bp_core_get_core_userdata( $inviter_user_id );
 312  
 313      if ( $member instanceof BP_Groups_Member ) {
 314          $invited_user_id = $member->user_id;
 315      } else if ( is_int( $member ) ) {
 316          $invited_user_id = $member;
 317      }
 318  
 319      // Trigger a BuddyPress Notification.
 320      if ( bp_is_active( 'notifications' ) ) {
 321          bp_notifications_add_notification( array(
 322              'user_id'          => $invited_user_id,
 323              'item_id'          => $group->id,
 324              'component_name'   => buddypress()->groups->id,
 325              'component_action' => 'group_invite',
 326          ) );
 327      }
 328  
 329      // Bail if member opted out of receiving this email.
 330      if ( 'no' === bp_get_user_meta( $invited_user_id, 'notification_groups_invite', true ) ) {
 331          return;
 332      }
 333  
 334      $invited_link = bp_core_get_user_domain( $invited_user_id ) . bp_get_groups_slug();
 335  
 336      $unsubscribe_args = array(
 337          'user_id'           => $invited_user_id,
 338          'notification_type' => 'groups-invitation',
 339      );
 340  
 341      $invite_message = '';
 342      $invitations = groups_get_invites( $args = array(
 343          'user_id'    => $invited_user_id,
 344          'item_id'    => $group->id,
 345          'inviter_id' => $inviter_user_id,
 346      ) );
 347      if ( $invitations ) {
 348          $invite_message = current( $invitations )->content;
 349      }
 350  
 351      $args         = array(
 352          'tokens' => array(
 353              'group'          => $group,
 354              'group.url'      => bp_get_group_permalink( $group ),
 355              'group.name'     => $group->name,
 356              'inviter.name'   => bp_core_get_userlink( $inviter_user_id, true, false, true ),
 357              'inviter.url'    => bp_core_get_user_domain( $inviter_user_id ),
 358              'inviter.id'     => $inviter_user_id,
 359              'invites.url'    => esc_url( $invited_link . '/invites/' ),
 360              'invite.message' => $invite_message,
 361              'unsubscribe'    => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),
 362          ),
 363      );
 364  
 365      bp_send_email( 'groups-invitation', (int) $invited_user_id, $args );
 366  }
 367  
 368  /** Notifications *************************************************************/
 369  
 370  /**
 371   * Format notifications for the Groups component.
 372   *
 373   * @since 1.0.0
 374   *
 375   * @param string $action            The kind of notification being rendered.
 376   * @param int    $item_id           The primary item ID.
 377   * @param int    $secondary_item_id The secondary item ID.
 378   * @param int    $total_items       The total number of messaging-related notifications
 379   *                                  waiting for the user.
 380   * @param string $format            'string' for BuddyBar-compatible notifications; 'array'
 381   *                                  for WP Toolbar. Default: 'string'.
 382   * @return string
 383   */
 384  function groups_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
 385  
 386      switch ( $action ) {
 387          case 'new_membership_request':
 388              $group_id = $item_id;
 389              $requesting_user_id = $secondary_item_id;
 390  
 391              $group = groups_get_group( $group_id );
 392              $group_link = bp_get_group_permalink( $group );
 393              $amount = 'single';
 394  
 395              // Set up the string and the filter
 396              // because different values are passed to the filters,
 397              // we'll return values inline.
 398              if ( (int) $total_items > 1 ) {
 399                  /* translators: 1: number of group membership requests. 2: group name. */
 400                  $text = sprintf( __( '%1$d new membership requests for the group "%2$s"', 'buddypress' ), (int) $total_items, $group->name );
 401                  $amount = 'multiple';
 402                  $notification_link = $group_link . 'admin/membership-requests/?n=1';
 403  
 404                  if ( 'string' == $format ) {
 405  
 406                      /**
 407                       * Filters groups multiple new membership request notification for string format.
 408                       *
 409                       * This is a dynamic filter that is dependent on item count and action.
 410                       * Complete filter - bp_groups_multiple_new_membership_requests_notification.
 411                       *
 412                       * @since 1.0.0
 413                       *
 414                       * @param string $string            HTML anchor tag for request.
 415                       * @param string $group_link        The permalink for the group.
 416                       * @param int    $total_items       Total number of membership requests.
 417                       * @param string $group->name       Name of the group.
 418                       * @param string $text              Notification content.
 419                       * @param string $notification_link The permalink for notification.
 420                       */
 421                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . 's_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $total_items, $group->name, $text, $notification_link );
 422                  } else {
 423  
 424                      /**
 425                       * Filters groups multiple new membership request notification for any non-string format.
 426                       *
 427                       * This is a dynamic filter that is dependent on item count and action.
 428                       * Complete filter - bp_groups_multiple_new_membership_requests_notification.
 429                       *
 430                       * @since 1.0.0
 431                       *
 432                       * @param array  $array             Array holding permalink and content for notification.
 433                       * @param string $group_link        The permalink for the group.
 434                       * @param int    $total_items       Total number of membership requests.
 435                       * @param string $group->name       Name of the group.
 436                       * @param string $text              Notification content.
 437                       * @param string $notification_link The permalink for notification.
 438                       */
 439                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . 's_notification', array(
 440                          'link' => $notification_link,
 441                          'text' => $text
 442                      ), $group_link, $total_items, $group->name, $text, $notification_link );
 443                  }
 444              } else {
 445                  $user_fullname = bp_core_get_user_displayname( $requesting_user_id );
 446                  /* translators: %s: member name */
 447                  $text = sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname );
 448                  $notification_link = $group_link . 'admin/membership-requests/?n=1';
 449  
 450                  if ( 'string' == $format ) {
 451  
 452                      /**
 453                       * Filters groups single new membership request notification for string format.
 454                       *
 455                       * This is a dynamic filter that is dependent on item count and action.
 456                       * Complete filter - bp_groups_single_new_membership_request_notification.
 457                       *
 458                       * @since 1.0.0
 459                       *
 460                       * @param string $string            HTML anchor tag for request.
 461                       * @param string $group_link        The permalink for the group.
 462                       * @param string $user_fullname     Full name of requesting user.
 463                       * @param string $group->name       Name of the group.
 464                       * @param string $text              Notification content.
 465                       * @param string $notification_link The permalink for notification.
 466                       */
 467                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $user_fullname, $group->name, $text, $notification_link );
 468                  } else {
 469  
 470                      /**
 471                       * Filters groups single new membership request notification for any non-string format.
 472                       *
 473                       * This is a dynamic filter that is dependent on item count and action.
 474                       * Complete filter - bp_groups_single_new_membership_request_notification.
 475                       *
 476                       * @since 1.0.0
 477                       *
 478                       * @param array  $array             Array holding permalink and content for notification.
 479                       * @param string $group_link        The permalink for the group.
 480                       * @param string $user_fullname     Full name of requesting user.
 481                       * @param string $group->name       Name of the group.
 482                       * @param string $text              Notification content.
 483                       * @param string $notification_link The permalink for notification.
 484                       */
 485                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
 486                          'link' => $notification_link,
 487                          'text' => $text
 488                      ), $group_link, $user_fullname, $group->name, $text, $notification_link );
 489                  }
 490              }
 491  
 492              break;
 493  
 494          case 'membership_request_accepted':
 495              $group_id = $item_id;
 496  
 497              $group = groups_get_group( $group_id );
 498              $group_link = bp_get_group_permalink( $group );
 499              $amount = 'single';
 500  
 501              if ( (int) $total_items > 1 ) {
 502                  /* translators: 1: number of accepted group membership requests. 2: group name. */
 503                  $text = sprintf( __( '%1$d accepted group membership requests for the group "%2$s"', 'buddypress' ), (int) $total_items, $group->name );
 504                  $amount = 'multiple';
 505                  $notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
 506  
 507                  if ( 'string' == $format ) {
 508  
 509                      /**
 510                       * Filters multiple accepted group membership requests notification for string format.
 511                       * Complete filter - bp_groups_multiple_membership_request_accepted_notification.
 512                       *
 513                       * @since 1.0.0
 514                       *
 515                       * @param string $string            HTML anchor tag for notification.
 516                       * @param int    $total_items       Total number of accepted requests.
 517                       * @param string $group->name       Name of the group.
 518                       * @param string $text              Notification content.
 519                       * @param string $notification_link The permalink for notification.
 520                       */
 521                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $total_items, $group->name, $text, $notification_link );
 522                  } else {
 523  
 524                      /**
 525                       * Filters multiple accepted group membership requests notification for non-string format.
 526                       * Complete filter - bp_groups_multiple_membership_request_accepted_notification.
 527                       *
 528                       * @since 1.0.0
 529                       *
 530                       * @param array  $array             Array holding permalink and content for notification
 531                       * @param int    $total_items       Total number of accepted requests.
 532                       * @param string $group->name       Name of the group.
 533                       * @param string $text              Notification content.
 534                       * @param string $notification_link The permalink for notification.
 535                       */
 536                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
 537                          'link' => $notification_link,
 538                          'text' => $text
 539                      ), $total_items, $group->name, $text, $notification_link );
 540                  }
 541              } else {
 542                  /* translators: %s: group name. */
 543                  $text = sprintf( __( 'Membership for group "%s" accepted', 'buddypress' ), $group->name );
 544                  $filter = 'bp_groups_single_membership_request_accepted_notification';
 545                  $notification_link = $group_link . '?n=1';
 546  
 547                  if ( 'string' == $format ) {
 548  
 549                      /**
 550                       * Filters single accepted group membership request notification for string format.
 551                       * Complete filter - bp_groups_single_membership_request_accepted_notification.
 552                       *
 553                       * @since 1.0.0
 554                       *
 555                       * @param string $string            HTML anchor tag for notification.
 556                       * @param string $group_link        The permalink for the group.
 557                       * @param string $group->name       Name of the group.
 558                       * @param string $text              Notification content.
 559                       * @param string $notification_link The permalink for notification.
 560                       */
 561                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
 562                  } else {
 563  
 564                      /**
 565                       * Filters single accepted group membership request notification for non-string format.
 566                       * Complete filter - bp_groups_single_membership_request_accepted_notification.
 567                       *
 568                       * @since 1.0.0
 569                       *
 570                       * @param array  $array             Array holding permalink and content for notification.
 571                       * @param string $group_link        The permalink for the group.
 572                       * @param string $group->name       Name of the group.
 573                       * @param string $text              Notification content.
 574                       * @param string $notification_link The permalink for notification.
 575                       */
 576                      return apply_filters( $filter, array(
 577                          'link' => $notification_link,
 578                          'text' => $text
 579                      ), $group_link, $group->name, $text, $notification_link );
 580                  }
 581              }
 582  
 583              break;
 584  
 585          case 'membership_request_rejected':
 586              $group_id = $item_id;
 587  
 588              $group = groups_get_group( $group_id );
 589              $group_link = bp_get_group_permalink( $group );
 590              $amount = 'single';
 591  
 592              if ( (int) $total_items > 1 ) {
 593                  /* translators: 1: number of accepted group membership requests. 2: group name. */
 594                  $text = sprintf( __( '%1$d rejected group membership requests for the group "%2$s"', 'buddypress' ), (int) $total_items, $group->name );
 595                  $amount = 'multiple';
 596                  $notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
 597  
 598                  if ( 'string' == $format ) {
 599  
 600                      /**
 601                       * Filters multiple rejected group membership requests notification for string format.
 602                       * Complete filter - bp_groups_multiple_membership_request_rejected_notification.
 603                       *
 604                       * @since 1.0.0
 605                       *
 606                       * @param string $string            HTML anchor tag for notification.
 607                       * @param int    $total_items       Total number of rejected requests.
 608                       * @param string $group->name       Name of the group.
 609                       * @param string $text              Notification content.
 610                       * @param string $notification_link The permalink for notification.
 611                       */
 612                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $total_items, $group->name );
 613                  } else {
 614  
 615                      /**
 616                       * Filters multiple rejected group membership requests notification for non-string format.
 617                       * Complete filter - bp_groups_multiple_membership_request_rejected_notification.
 618                       *
 619                       * @since 1.0.0
 620                       *
 621                       * @param array  $array             Array holding permalink and content for notification.
 622                       * @param int    $total_items       Total number of rejected requests.
 623                       * @param string $group->name       Name of the group.
 624                       * @param string $text              Notification content.
 625                       * @param string $notification_link The permalink for notification.
 626                       */
 627                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
 628                          'link' => $notification_link,
 629                          'text' => $text
 630                      ), $total_items, $group->name, $text, $notification_link );
 631                  }
 632              } else {
 633                  /* translators: %s: group name. */
 634                  $text = sprintf( __( 'Membership for group "%s" rejected', 'buddypress' ), $group->name );
 635                  $notification_link = $group_link . '?n=1';
 636  
 637                  if ( 'string' == $format ) {
 638  
 639                      /**
 640                       * Filters single rejected group membership requests notification for string format.
 641                       * Complete filter - bp_groups_single_membership_request_rejected_notification.
 642                       *
 643                       * @since 1.0.0
 644                       *
 645                       * @param string $string            HTML anchor tag for notification.
 646                       * @param int    $group_link        The permalink for the group.
 647                       * @param string $group->name       Name of the group.
 648                       * @param string $text              Notification content.
 649                       * @param string $notification_link The permalink for notification.
 650                       */
 651                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
 652                  } else {
 653  
 654                      /**
 655                       * Filters single rejected group membership requests notification for non-string format.
 656                       * Complete filter - bp_groups_single_membership_request_rejected_notification.
 657                       *
 658                       * @since 1.0.0
 659                       *
 660                       * @param array  $array             Array holding permalink and content for notification.
 661                       * @param int    $group_link        The permalink for the group.
 662                       * @param string $group->name       Name of the group.
 663                       * @param string $text              Notification content.
 664                       * @param string $notification_link The permalink for notification.
 665                       */
 666                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
 667                          'link' => $notification_link,
 668                          'text' => $text
 669                      ), $group_link, $group->name, $text, $notification_link );
 670                  }
 671              }
 672  
 673              break;
 674  
 675          case 'member_promoted_to_admin':
 676              $group_id = $item_id;
 677  
 678              $group = groups_get_group( $group_id );
 679              $group_link = bp_get_group_permalink( $group );
 680              $amount = 'single';
 681  
 682              if ( (int) $total_items > 1 ) {
 683                  /* translators: %d: number of groups the user has been promoted admin for */
 684                  $text = sprintf( __( 'You were promoted to an admin in %d groups', 'buddypress' ), (int) $total_items );
 685                  $amount = 'multiple';
 686                  $notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
 687  
 688                  if ( 'string' == $format ) {
 689                      /**
 690                       * Filters multiple promoted to group admin notification for string format.
 691                       * Complete filter - bp_groups_multiple_member_promoted_to_admin_notification.
 692                       *
 693                       * @since 1.0.0
 694                       *
 695                       * @param string $string            HTML anchor tag for notification.
 696                       * @param int    $total_items       Total number of rejected requests.
 697                       * @param string $text              Notification content.
 698                       * @param string $notification_link The permalink for notification.
 699                       */
 700                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $total_items, $text, $notification_link );
 701                  } else {
 702                      /**
 703                       * Filters multiple promoted to group admin notification for non-string format.
 704                       * Complete filter - bp_groups_multiple_member_promoted_to_admin_notification.
 705                       *
 706                       * @since 1.0.0
 707                       *
 708                       * @param array  $array             Array holding permalink and content for notification.
 709                       * @param int    $total_items       Total number of rejected requests.
 710                       * @param string $text              Notification content.
 711                       * @param string $notification_link The permalink for notification.
 712                       */
 713                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
 714                          'link' => $notification_link,
 715                          'text' => $text
 716                      ), $total_items, $text, $notification_link );
 717                  }
 718              } else {
 719                  /* translators: %s: group name. */
 720                  $text = sprintf( __( 'You were promoted to an admin in the group "%s"', 'buddypress' ), $group->name );
 721                  $notification_link = $group_link . '?n=1';
 722  
 723                  if ( 'string' == $format ) {
 724                      /**
 725                       * Filters single promoted to group admin notification for non-string format.
 726                       * Complete filter - bp_groups_single_member_promoted_to_admin_notification.
 727                       *
 728                       * @since 1.0.0
 729                       *
 730                       * @param string $string            HTML anchor tag for notification.
 731                       * @param int    $group_link        The permalink for the group.
 732                       * @param string $group->name       Name of the group.
 733                       * @param string $text              Notification content.
 734                       * @param string $notification_link The permalink for notification.
 735                       */
 736                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
 737                  } else {
 738                      /**
 739                       * Filters single promoted to group admin notification for non-string format.
 740                       * Complete filter - bp_groups_single_member_promoted_to_admin_notification.
 741                       *
 742                       * @since 1.0.0
 743                       *
 744                       * @param array  $array             Array holding permalink and content for notification.
 745                       * @param int    $group_link        The permalink for the group.
 746                       * @param string $group->name       Name of the group.
 747                       * @param string $text              Notification content.
 748                       * @param string $notification_link The permalink for notification.
 749                       */
 750                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
 751                          'link' => $notification_link,
 752                          'text' => $text
 753                      ), $group_link, $group->name, $text, $notification_link );
 754                  }
 755              }
 756  
 757              break;
 758  
 759          case 'member_promoted_to_mod':
 760              $group_id = $item_id;
 761  
 762              $group = groups_get_group( $group_id );
 763              $group_link = bp_get_group_permalink( $group );
 764              $amount = 'single';
 765  
 766              if ( (int) $total_items > 1 ) {
 767                  /* translators: %d: number of groups the user has been promoted mod for */
 768                  $text = sprintf( __( 'You were promoted to a mod in %d groups', 'buddypress' ), (int) $total_items );
 769                  $amount = 'multiple';
 770                  $notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
 771  
 772                  if ( 'string' == $format ) {
 773                      /**
 774                       * Filters multiple promoted to group mod notification for string format.
 775                       * Complete filter - bp_groups_multiple_member_promoted_to_mod_notification.
 776                       *
 777                       * @since 1.0.0
 778                       *
 779                       * @param string $string            HTML anchor tag for notification.
 780                       * @param int    $total_items       Total number of rejected requests.
 781                       * @param string $text              Notification content.
 782                       * @param string $notification_link The permalink for notification.
 783                       */
 784                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $total_items, $text, $notification_link );
 785                  } else {
 786                      /**
 787                       * Filters multiple promoted to group mod notification for non-string format.
 788                       * Complete filter - bp_groups_multiple_member_promoted_to_mod_notification.
 789                       *
 790                       * @since 1.0.0
 791                       *
 792                       * @param array  $array             Array holding permalink and content for notification.
 793                       * @param int    $total_items       Total number of rejected requests.
 794                       * @param string $text              Notification content.
 795                       * @param string $notification_link The permalink for notification.
 796                       */
 797                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
 798                          'link' => $notification_link,
 799                          'text' => $text
 800                      ), $total_items, $text, $notification_link );
 801                  }
 802              } else {
 803                  /* translators: %s: group name. */
 804                  $text = sprintf( __( 'You were promoted to a mod in the group "%s"', 'buddypress' ), $group->name );
 805                  $notification_link = $group_link . '?n=1';
 806  
 807                  if ( 'string' == $format ) {
 808                      /**
 809                       * Filters single promoted to group mod notification for string format.
 810                       * Complete filter - bp_groups_single_member_promoted_to_mod_notification.
 811                       *
 812                       * @since 1.0.0
 813                       *
 814                       * @param string $string            HTML anchor tag for notification.
 815                       * @param int    $group_link        The permalink for the group.
 816                       * @param string $group->name       Name of the group.
 817                       * @param string $text              Notification content.
 818                       * @param string $notification_link The permalink for notification.
 819                       */
 820                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
 821                  } else {
 822                      /**
 823                       * Filters single promoted to group admin notification for non-string format.
 824                       * Complete filter - bp_groups_single_member_promoted_to_mod_notification.
 825                       *
 826                       * @since 1.0.0
 827                       *
 828                       * @param array  $array             Array holding permalink and content for notification.
 829                       * @param int    $group_link        The permalink for the group.
 830                       * @param string $group->name       Name of the group.
 831                       * @param string $text              Notification content.
 832                       * @param string $notification_link The permalink for notification.
 833                       */
 834                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
 835                          'link' => $notification_link,
 836                          'text' => $text
 837                      ), $group_link, $group->name, $text, $notification_link );
 838                  }
 839              }
 840  
 841              break;
 842  
 843          case 'group_invite':
 844              $group_id = $item_id;
 845              $group = groups_get_group( $group_id );
 846              $group_link = bp_get_group_permalink( $group );
 847              $amount = 'single';
 848  
 849              $notification_link = bp_loggedin_user_domain() . bp_get_groups_slug() . '/invites/?n=1';
 850  
 851              if ( (int) $total_items > 1 ) {
 852                  /* translators: %d: number of group invites */
 853                  $text = sprintf( __( 'You have %d new group invitations', 'buddypress' ), (int) $total_items );
 854                  $amount = 'multiple';
 855  
 856                  if ( 'string' == $format ) {
 857                      /**
 858                       * Filters multiple group invitation notification for string format.
 859                       * Complete filter - bp_groups_multiple_group_invite_notification.
 860                       *
 861                       * @since 1.0.0
 862                       *
 863                       * @param string $string            HTML anchor tag for notification.
 864                       * @param int    $total_items       Total number of rejected requests.
 865                       * @param string $text              Notification content.
 866                       * @param string $notification_link The permalink for notification.
 867                       */
 868                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $total_items, $text, $notification_link );
 869                  } else {
 870                      /**
 871                       * Filters multiple group invitation notification for non-string format.
 872                       * Complete filter - bp_groups_multiple_group_invite_notification.
 873                       *
 874                       * @since 1.0.0
 875                       *
 876                       * @param array  $array             Array holding permalink and content for notification.
 877                       * @param int    $total_items       Total number of rejected requests.
 878                       * @param string $text              Notification content.
 879                       * @param string $notification_link The permalink for notification.
 880                       */
 881                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
 882                          'link' => $notification_link,
 883                          'text' => $text
 884                      ), $total_items, $text, $notification_link );
 885                  }
 886              } else {
 887                  /* translators: %s: group name. */
 888                  $text = sprintf( __( 'You have an invitation to the group: %s', 'buddypress' ), $group->name );
 889                  $filter = 'bp_groups_single_group_invite_notification';
 890  
 891                  if ( 'string' == $format ) {
 892                      /**
 893                       * Filters single group invitation notification for string format.
 894                       * Complete filter - bp_groups_single_group_invite_notification.
 895                       *
 896                       * @since 1.0.0
 897                       *
 898                       * @param string $string            HTML anchor tag for notification.
 899                       * @param int    $group_link        The permalink for the group.
 900                       * @param string $group->name       Name of the group.
 901                       * @param string $text              Notification content.
 902                       * @param string $notification_link The permalink for notification.
 903                       */
 904                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
 905                  } else {
 906                      /**
 907                       * Filters single group invitation notification for non-string format.
 908                       * Complete filter - bp_groups_single_group_invite_notification.
 909                       *
 910                       * @since 1.0.0
 911                       *
 912                       * @param array  $array             Array holding permalink and content for notification.
 913                       * @param int    $group_link        The permalink for the group.
 914                       * @param string $group->name       Name of the group.
 915                       * @param string $text              Notification content.
 916                       * @param string $notification_link The permalink for notification.
 917                       */
 918                      return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
 919                          'link' => $notification_link,
 920                          'text' => $text
 921                      ), $group_link, $group->name, $text, $notification_link );
 922                  }
 923              }
 924  
 925              break;
 926  
 927          default:
 928  
 929              /**
 930               * Filters plugin-added group-related custom component_actions.
 931               *
 932               * @since 2.4.0
 933               *
 934               * @param string $notification      Null value.
 935               * @param int    $item_id           The primary item ID.
 936               * @param int    $secondary_item_id The secondary item ID.
 937               * @param int    $total_items       The total number of messaging-related notifications
 938               *                                  waiting for the user.
 939               * @param string $format            'string' for BuddyBar-compatible notifications;
 940               *                                  'array' for WP Toolbar.
 941               */
 942              $custom_action_notification = apply_filters( 'bp_groups_' . $action . '_notification', null, $item_id, $secondary_item_id, $total_items, $format );
 943  
 944              if ( ! is_null( $custom_action_notification ) ) {
 945                  return $custom_action_notification;
 946              }
 947  
 948              break;
 949      }
 950  
 951      /**
 952       * Fires right before returning the formatted group notifications.
 953       *
 954       * @since 1.0.0
 955       *
 956       * @param string $action            The type of notification being rendered.
 957       * @param int    $item_id           The primary item ID.
 958       * @param int    $secondary_item_id The secondary item ID.
 959       * @param int    $total_items       Total amount of items to format.
 960       */
 961      do_action( 'groups_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
 962  
 963      return false;
 964  }
 965  
 966  /**
 967   * Remove all notifications for any member belonging to a specific group.
 968   *
 969   * @since 1.9.0
 970   *
 971   * @param int $group_id ID of the group.
 972   */
 973  function bp_groups_delete_group_delete_all_notifications( $group_id ) {
 974      if ( bp_is_active( 'notifications' ) ) {
 975          bp_notifications_delete_all_notifications_by_type( $group_id, buddypress()->groups->id );
 976      }
 977  }
 978  add_action( 'groups_delete_group', 'bp_groups_delete_group_delete_all_notifications', 10 );
 979  
 980  /**
 981   * Remove Group invite notification when a user is uninvited.
 982   *
 983   * @since 5.0.0
 984   *
 985   * @param int $group_id ID of the group being uninvited from.
 986   * @param int $user_id  ID of the user being uninvited.
 987   */
 988  function bp_groups_uninvite_user_delete_group_invite_notification( $group_id = 0, $user_id = 0 ) {
 989      if ( ! bp_is_active( 'notifications' ) || ! $group_id || ! $user_id ) {
 990          return;
 991      }
 992  
 993      bp_notifications_delete_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'group_invite' );
 994  }
 995  add_action( 'groups_uninvite_user', 'bp_groups_uninvite_user_delete_group_invite_notification', 10, 2 );
 996  
 997  /**
 998   * When a demotion takes place, delete any corresponding promotion notifications.
 999   *
1000   * @since 2.0.0
1001   *
1002   * @param int $user_id  ID of the user.
1003   * @param int $group_id ID of the group.
1004   */
1005  function bp_groups_delete_promotion_notifications( $user_id = 0, $group_id = 0 ) {
1006      if ( bp_is_active( 'notifications' ) && ! empty( $group_id ) && ! empty( $user_id ) ) {
1007          bp_notifications_delete_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'member_promoted_to_admin' );
1008          bp_notifications_delete_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'member_promoted_to_mod' );
1009      }
1010  }
1011  add_action( 'groups_demoted_member', 'bp_groups_delete_promotion_notifications', 10, 2 );
1012  
1013  /**
1014   * Mark notifications read when a member accepts a group invitation.
1015   *
1016   * @since 1.9.0
1017   *
1018   * @param int $user_id  ID of the user.
1019   * @param int $group_id ID of the group.
1020   */
1021  function bp_groups_accept_invite_mark_notifications( $user_id, $group_id ) {
1022      if ( bp_is_active( 'notifications' ) ) {
1023          bp_notifications_mark_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'group_invite' );
1024      }
1025  }
1026  add_action( 'groups_accept_invite', 'bp_groups_accept_invite_mark_notifications', 10, 2 );
1027  add_action( 'groups_reject_invite', 'bp_groups_accept_invite_mark_notifications', 10, 2 );
1028  add_action( 'groups_delete_invite', 'bp_groups_accept_invite_mark_notifications', 10, 2 );
1029  
1030  /**
1031   * Mark notifications read when a member's group membership request is granted.
1032   *
1033   * @since 2.8.0
1034   *
1035   * @param int $user_id  ID of the user.
1036   * @param int $group_id ID of the group.
1037   */
1038  function bp_groups_accept_request_mark_notifications( $user_id, $group_id ) {
1039      if ( bp_is_active( 'notifications' ) ) {
1040          // First null parameter marks read for all admins.
1041          bp_notifications_mark_notifications_by_item_id( null, $group_id, buddypress()->groups->id, 'new_membership_request', $user_id );
1042      }
1043  }
1044  add_action( 'groups_membership_accepted', 'bp_groups_accept_request_mark_notifications', 10, 2 );
1045  add_action( 'groups_membership_rejected', 'bp_groups_accept_request_mark_notifications', 10, 2 );
1046  
1047  /**
1048   * Mark notifications read when a member views their group memberships.
1049   *
1050   * @since 1.9.0
1051   */
1052  function bp_groups_screen_my_groups_mark_notifications() {
1053  
1054      // Delete group request notifications for the user.
1055      if ( isset( $_GET['n'] ) && bp_is_active( 'notifications' ) ) {
1056  
1057          // Get the necessary ID's.
1058          $group_id = buddypress()->groups->id;
1059          $user_id  = bp_loggedin_user_id();
1060  
1061          // Mark notifications read.
1062          bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'membership_request_accepted' );
1063          bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'membership_request_rejected' );
1064          bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'member_promoted_to_mod'      );
1065          bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'member_promoted_to_admin'    );
1066      }
1067  }
1068  add_action( 'groups_screen_my_groups',  'bp_groups_screen_my_groups_mark_notifications', 10 );
1069  add_action( 'groups_screen_group_home', 'bp_groups_screen_my_groups_mark_notifications', 10 );
1070  
1071  /**
1072   * Mark group invitation notifications read when a member views their invitations.
1073   *
1074   * @since 1.9.0
1075   */
1076  function bp_groups_screen_invites_mark_notifications() {
1077      if ( bp_is_active( 'notifications' ) ) {
1078          bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'group_invite' );
1079      }
1080  }
1081  add_action( 'groups_screen_group_invites', 'bp_groups_screen_invites_mark_notifications', 10 );
1082  
1083  /**
1084   * Mark group join requests read when an admin or moderator visits the group administration area.
1085   *
1086   * @since 1.9.0
1087   */
1088  function bp_groups_screen_group_admin_requests_mark_notifications() {
1089      if ( bp_is_active( 'notifications' ) ) {
1090          bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'new_membership_request' );
1091      }
1092  }
1093  add_action( 'groups_screen_group_admin_requests', 'bp_groups_screen_group_admin_requests_mark_notifications', 10 );
1094  
1095  /**
1096   * Delete new group membership notifications when a user is being deleted.
1097   *
1098   * @since 1.9.0
1099   *
1100   * @param int $user_id ID of the user.
1101   */
1102  function bp_groups_remove_data_for_user_notifications( $user_id ) {
1103      if ( bp_is_active( 'notifications' ) ) {
1104          bp_notifications_delete_notifications_from_user( $user_id, buddypress()->groups->id, 'new_membership_request' );
1105      }
1106  }
1107  add_action( 'groups_remove_data_for_user', 'bp_groups_remove_data_for_user_notifications', 10 );
1108  
1109  /**
1110   * Render the group settings fields on the Notification Settings page.
1111   *
1112   * @since 1.0.0
1113   */
1114  function groups_screen_notification_settings() {
1115  
1116      if ( !$group_invite = bp_get_user_meta( bp_displayed_user_id(), 'notification_groups_invite', true ) )
1117          $group_invite  = 'yes';
1118  
1119      if ( !$group_update = bp_get_user_meta( bp_displayed_user_id(), 'notification_groups_group_updated', true ) )
1120          $group_update  = 'yes';
1121  
1122      if ( !$group_promo = bp_get_user_meta( bp_displayed_user_id(), 'notification_groups_admin_promotion', true ) )
1123          $group_promo   = 'yes';
1124  
1125      if ( !$group_request = bp_get_user_meta( bp_displayed_user_id(), 'notification_groups_membership_request', true ) )
1126          $group_request = 'yes';
1127  
1128      if ( ! $group_request_completed = bp_get_user_meta( bp_displayed_user_id(), 'notification_membership_request_completed', true ) ) {
1129          $group_request_completed = 'yes';
1130      }
1131      ?>
1132  
1133      <table class="notification-settings" id="groups-notification-settings">
1134          <thead>
1135              <tr>
1136                  <th class="icon"></th>
1137                  <th class="title"><?php _ex( 'Groups', 'Group settings on notification settings page', 'buddypress' ) ?></th>
1138                  <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
1139                  <th class="no"><?php _e( 'No', 'buddypress' )?></th>
1140              </tr>
1141          </thead>
1142  
1143          <tbody>
1144              <tr id="groups-notification-settings-invitation">
1145                  <td></td>
1146                  <td><?php _ex( 'A member invites you to join a group', 'group settings on notification settings page','buddypress' ) ?></td>
1147                  <td class="yes"><input type="radio" name="notifications[notification_groups_invite]" id="notification-groups-invite-yes" value="yes" <?php checked( $group_invite, 'yes', true ) ?>/><label for="notification-groups-invite-yes" class="bp-screen-reader-text"><?php
1148                      /* translators: accessibility text */
1149                      _e( 'Yes, send email', 'buddypress' );
1150                  ?></label></td>
1151                  <td class="no"><input type="radio" name="notifications[notification_groups_invite]" id="notification-groups-invite-no" value="no" <?php checked( $group_invite, 'no', true ) ?>/><label for="notification-groups-invite-no" class="bp-screen-reader-text"><?php
1152                      /* translators: accessibility text */
1153                      _e( 'No, do not send email', 'buddypress' );
1154                  ?></label></td>
1155              </tr>
1156              <tr id="groups-notification-settings-info-updated">
1157                  <td></td>
1158                  <td><?php _ex( 'Group information is updated', 'group settings on notification settings page', 'buddypress' ) ?></td>
1159                  <td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" id="notification-groups-group-updated-yes" value="yes" <?php checked( $group_update, 'yes', true ) ?>/><label for="notification-groups-group-updated-yes" class="bp-screen-reader-text"><?php
1160                      /* translators: accessibility text */
1161                      _e( 'Yes, send email', 'buddypress' );
1162                  ?></label></td>
1163                  <td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" id="notification-groups-group-updated-no" value="no" <?php checked( $group_update, 'no', true ) ?>/><label for="notification-groups-group-updated-no" class="bp-screen-reader-text"><?php
1164                      /* translators: accessibility text */
1165                      _e( 'No, do not send email', 'buddypress' );
1166                  ?></label></td>
1167              </tr>
1168              <tr id="groups-notification-settings-promoted">
1169                  <td></td>
1170                  <td><?php _ex( 'You are promoted to a group administrator or moderator', 'group settings on notification settings page', 'buddypress' ) ?></td>
1171                  <td class="yes"><input type="radio" name="notifications[notification_groups_admin_promotion]" id="notification-groups-admin-promotion-yes" value="yes" <?php checked( $group_promo, 'yes', true ) ?>/><label for="notification-groups-admin-promotion-yes" class="bp-screen-reader-text"><?php
1172                      /* translators: accessibility text */
1173                      _e( 'Yes, send email', 'buddypress' );
1174                  ?></label></td>
1175                  <td class="no"><input type="radio" name="notifications[notification_groups_admin_promotion]" id="notification-groups-admin-promotion-no" value="no" <?php checked( $group_promo, 'no', true ) ?>/><label for="notification-groups-admin-promotion-no" class="bp-screen-reader-text"><?php
1176                      /* translators: accessibility text */
1177                      _e( 'No, do not send email', 'buddypress' );
1178                  ?></label></td>
1179              </tr>
1180              <tr id="groups-notification-settings-request">
1181                  <td></td>
1182                  <td><?php _ex( 'A member requests to join a private group for which you are an admin', 'group settings on notification settings page', 'buddypress' ) ?></td>
1183                  <td class="yes"><input type="radio" name="notifications[notification_groups_membership_request]" id="notification-groups-membership-request-yes" value="yes" <?php checked( $group_request, 'yes', true ) ?>/><label for="notification-groups-membership-request-yes" class="bp-screen-reader-text"><?php
1184                      /* translators: accessibility text */
1185                      _e( 'Yes, send email', 'buddypress' );
1186                  ?></label></td>
1187                  <td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" id="notification-groups-membership-request-no" value="no" <?php checked( $group_request, 'no', true ) ?>/><label for="notification-groups-membership-request-no" class="bp-screen-reader-text"><?php
1188                      /* translators: accessibility text */
1189                      _e( 'No, do not send email', 'buddypress' );
1190                  ?></label></td>
1191              </tr>
1192              <tr id="groups-notification-settings-request-completed">
1193                  <td></td>
1194                  <td><?php _ex( 'Your request to join a group has been approved or denied', 'group settings on notification settings page', 'buddypress' ) ?></td>
1195                  <td class="yes"><input type="radio" name="notifications[notification_membership_request_completed]" id="notification-groups-membership-request-completed-yes" value="yes" <?php checked( $group_request_completed, 'yes', true ) ?>/><label for="notification-groups-membership-request-completed-yes" class="bp-screen-reader-text"><?php
1196                      /* translators: accessibility text */
1197                      _e( 'Yes, send email', 'buddypress' );
1198                  ?></label></td>
1199                  <td class="no"><input type="radio" name="notifications[notification_membership_request_completed]" id="notification-groups-membership-request-completed-no" value="no" <?php checked( $group_request_completed, 'no', true ) ?>/><label for="notification-groups-membership-request-completed-no" class="bp-screen-reader-text"><?php
1200                      /* translators: accessibility text */
1201                      _e( 'No, do not send email', 'buddypress' );
1202                  ?></label></td>
1203              </tr>
1204  
1205              <?php
1206  
1207              /**
1208               * Fires at the end of the available group settings fields on Notification Settings page.
1209               *
1210               * @since 1.0.0
1211               */
1212              do_action( 'groups_screen_notification_settings' ); ?>
1213  
1214          </tbody>
1215      </table>
1216  
1217  <?php
1218  }
1219  add_action( 'bp_notification_settings', 'groups_screen_notification_settings' );


Generated: Thu Jul 2 01:01:34 2020 Cross-referenced by PHPXref 0.7.1