buddypress/bp-xprofile/bp-xprofile-actions.php
John James Jacoby e6fa66ffe9 Theme Compatibility:
* Remove errant references to bp_core_load_template()
* See: #3741.

git-svn-id: https://buddypress.svn.wordpress.org/trunk@6291 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
2012-09-03 01:33:13 +00:00

45 lines
1.4 KiB
PHP

<?php
/**
* BuddyPress XProfile Actions
*
* Action functions are exactly the same as screen functions, however they do not
* have a template screen associated with them. Usually they will send the user
* back to the default screen after execution.
*
* @package BuddyPress
* @subpackage XProfileActions
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* This function runs when an action is set for a screen:
* example.com/members/andy/profile/change-avatar/ [delete-avatar]
*
* The function will delete the active avatar for a user.
*
* @package BuddyPress Xprofile
* @uses bp_core_delete_avatar() Deletes the active avatar for the logged in user.
* @uses add_action() Runs a specific function for an action when it fires.
*/
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 avatar was deleted successfully!', 'buddypress' ) );
else
bp_core_add_message( __( 'There was a problem deleting that avatar, please try again.', 'buddypress' ), 'error' );
bp_core_redirect( wp_get_referer() );
}
add_action( 'bp_actions', 'xprofile_action_delete_avatar' );