[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-members/actions/ -> delete-avatar.php (source)

   1  <?php
   2  /**
   3   * Members: Avatar deletion action handler
   4   *
   5   * @package BuddyPress
   6   * @subpackage MembersActions
   7   * @since 6.0.0
   8   */
   9  
  10  /**
  11   * This function runs when an action is set for a screen:
  12   * example.com/members/andy/profile/change-avatar/ [delete-avatar]
  13   *
  14   * The function will delete the active avatar for a user.
  15   *
  16   * @since 6.0.0
  17   */
  18  function bp_members_action_delete_avatar() {
  19  
  20      if ( ! bp_is_user_change_avatar() || ! bp_is_action_variable( 'delete-avatar', 0 ) ) {
  21          return false;
  22      }
  23  
  24      // Check the nonce.
  25      check_admin_referer( 'bp_delete_avatar_link' );
  26  
  27      if ( ! bp_is_my_profile() && ! bp_current_user_can( 'bp_moderate' ) ) {
  28          return false;
  29      }
  30  
  31      if ( bp_core_delete_existing_avatar( array( 'item_id' => bp_displayed_user_id() ) ) ) {
  32          bp_core_add_message( __( 'Your profile photo was deleted successfully!', 'buddypress' ) );
  33      } else {
  34          bp_core_add_message( __( 'There was a problem deleting your profile photo. Please try again.', 'buddypress' ), 'error' );
  35      }
  36  
  37      bp_core_redirect( wp_get_referer() );
  38  }
  39  add_action( 'bp_actions', 'bp_members_action_delete_avatar' );


Generated: Wed Aug 12 01:01:32 2020 Cross-referenced by PHPXref 0.7.1