[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * XProfile: Avatar deletion action handler
   4   *
   5   * @package BuddyPress
   6   * @subpackage XProfileActions
   7   * @since 3.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 1.0.0
  17   *
  18   */
  19  function xprofile_action_delete_avatar() {
  20  
  21      if ( ! bp_is_user_change_avatar() || ! bp_is_action_variable( 'delete-avatar', 0 ) ) {
  22          return false;
  23      }
  24  
  25      // Check the nonce.
  26      check_admin_referer( 'bp_delete_avatar_link' );
  27  
  28      if ( ! bp_is_my_profile() && ! bp_current_user_can( 'bp_moderate' ) ) {
  29          return false;
  30      }
  31  
  32      if ( bp_core_delete_existing_avatar( array( 'item_id' => bp_displayed_user_id() ) ) ) {
  33          bp_core_add_message( __( 'Your profile photo was deleted successfully!', 'buddypress' ) );
  34      } else {
  35          bp_core_add_message( __( 'There was a problem deleting your profile photo. Please try again.', 'buddypress' ), 'error' );
  36      }
  37  
  38      bp_core_redirect( wp_get_referer() );
  39  }
  40  add_action( 'bp_actions', 'xprofile_action_delete_avatar' );


Generated: Sat Jan 25 01:01:42 2020 Cross-referenced by PHPXref 0.7.1