[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-friends/screens/ -> requests.php (source)

   1  <?php
   2  /**
   3   * Friends: User's "Friends > Requests" screen handler
   4   *
   5   * @package BuddyPress
   6   * @subpackage FriendsScreens
   7   * @since 3.0.0
   8   */
   9  
  10  /**
  11   * Catch and process the Requests page.
  12   *
  13   * @since 1.0.0
  14   */
  15  function friends_screen_requests() {
  16      if ( bp_is_action_variable( 'accept', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
  17          // Check the nonce.
  18          check_admin_referer( 'friends_accept_friendship' );
  19  
  20          if ( friends_accept_friendship( bp_action_variable( 1 ) ) )
  21              bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) );
  22          else
  23              bp_core_add_message( __( 'Friendship could not be accepted', 'buddypress' ), 'error' );
  24  
  25          bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) );
  26  
  27      } elseif ( bp_is_action_variable( 'reject', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
  28          // Check the nonce.
  29          check_admin_referer( 'friends_reject_friendship' );
  30  
  31          if ( friends_reject_friendship( bp_action_variable( 1 ) ) )
  32              bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) );
  33          else
  34              bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' );
  35  
  36          bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) );
  37  
  38      } elseif ( bp_is_action_variable( 'cancel', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
  39          // Check the nonce.
  40          check_admin_referer( 'friends_withdraw_friendship' );
  41  
  42          if ( friends_withdraw_friendship( bp_loggedin_user_id(), bp_action_variable( 1 ) ) )
  43              bp_core_add_message( __( 'Friendship request withdrawn', 'buddypress' ) );
  44          else
  45              bp_core_add_message( __( 'Friendship request could not be withdrawn', 'buddypress' ), 'error' );
  46  
  47          bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) );
  48      }
  49  
  50      /**
  51       * Fires before the loading of template for the friends requests page.
  52       *
  53       * @since 1.0.0
  54       */
  55      do_action( 'friends_screen_requests' );
  56  
  57      /**
  58       * Filters the template used to display the My Friends page.
  59       *
  60       * @since 1.0.0
  61       *
  62       * @param string $template Path to the friends request template to load.
  63       */
  64      bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
  65  }


Generated: Mon Dec 9 01:01:38 2019 Cross-referenced by PHPXref 0.7.1