xprofile_action_delete_avatar()

Deletes the active avatar for a user.

Description

This function runs when an action is set for a screen: example.com/members/andy/profile/change-avatar/ [delete-avatar]

Source

File: bp-xprofile/actions/delete-avatar.php

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function xprofile_action_delete_avatar() {
 
    if ( ! bp_is_user_change_avatar() || ! bp_is_action_variable( 'delete-avatar', 0 ) ) {
        return false;
    }
 
    // Check the nonce.
    check_admin_referer( 'bp_delete_avatar_link' );
 
    if ( ! bp_is_my_profile() && ! bp_current_user_can( 'bp_moderate' ) ) {
        return false;
    }
 
    if ( bp_core_delete_existing_avatar( array( 'item_id' => bp_displayed_user_id() ) ) ) {
        bp_core_add_message( __( 'Your profile photo was deleted successfully!', 'buddyboss' ) );
    } else {
        bp_core_add_message( __( 'There was a problem deleting your profile photo. Please try again.', 'buddyboss' ), 'error' );
    }
 
    bp_core_redirect( wp_get_referer() );
}

Changelog

Changelog
Version Description
BuddyPress 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.