BP_REST_Account_Settings_Options_Endpoint::update_delete_account_fields( WP_REST_Request $request )
Delete Account “Export Data”.
Description
Parameters
- $request
-
(Required) Full details about the request.
Return
(array|bool|void)
Source
File: bp-settings/classes/class-bp-rest-account-settings-options-endpoint.php
public function update_delete_account_fields( $request ) { $post_fields = $request->get_param( 'fields' ); $error = false; $notice = false; if ( isset( $post_fields['delete-account-understand'] ) && ! empty( $post_fields['delete-account-understand'] ) && isset( $post_fields['member-delete-account'] ) && ! empty( $post_fields['member-delete-account'] ) ) { $bp = buddypress(); // The instance. add_filter( 'bp_displayed_user_id', array( $this, 'bp_rest_get_displayed_user' ), 999 ); // The core userdata of the user who is currently being displayed. $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() ); // Fetch the full name displayed user. $bp->displayed_user->fullname = isset( $bp->displayed_user->userdata->display_name ) ? $bp->displayed_user->userdata->display_name : ''; // The domain for the user currently being displayed. $bp->displayed_user->domain = bp_core_get_user_domain( bp_displayed_user_id() ); if ( bp_disable_account_deletion() && ! bp_current_user_can( 'delete_users' ) ) { $error = __( 'Sorry, You can not able to delete the account.', 'buddyboss' ); } elseif ( bp_core_delete_account( bp_displayed_user_id() ) ) { $username = bp_get_displayed_user_fullname(); /* translators: %s: User's full name. */ $notice = sprintf( __( '%s was successfully deleted.', 'buddyboss' ), $username ); } remove_filter( 'bp_displayed_user_id', array( $this, 'bp_rest_get_displayed_user' ), 999 ); } else { $error = __( 'No changes were made to your account.', 'buddyboss' ); } return array( 'error' => $error, 'notice' => $notice, ); }
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.