bp_members_action_delete_avatar()

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


Description Description

The function will delete the active avatar for a user.


Source Source

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

function bp_members_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!', 'buddypress' ) );
	} else {
		bp_core_add_message( __( 'There was a problem deleting your profile photo. Please try again.', 'buddypress' ), 'error' );
	}

	bp_core_redirect( wp_get_referer() );
}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.