Title: _wp_personal_data_handle_actions
Published: October 5, 2018
Last modified: May 20, 2026

---

# _wp_personal_data_handle_actions()

## In this article

 * [Source](https://developer.wordpress.org/reference/functions/_wp_personal_data_handle_actions/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/_wp_personal_data_handle_actions/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_wp_personal_data_handle_actions/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/_wp_personal_data_handle_actions/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Handle list table actions.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/_wp_personal_data_handle_actions/?output_format=md#source)󠁿

    ```php
    function _wp_personal_data_handle_actions() {
    	if ( isset( $_POST['privacy_action_email_retry'] ) ) {
    		check_admin_referer( 'bulk-privacy_requests' );

    		$request_id = absint( current( array_keys( (array) wp_unslash( $_POST['privacy_action_email_retry'] ) ) ) );
    		$result     = _wp_privacy_resend_request( $request_id );

    		if ( is_wp_error( $result ) ) {
    			add_settings_error(
    				'privacy_action_email_retry',
    				'privacy_action_email_retry',
    				$result->get_error_message(),
    				'error'
    			);
    		} else {
    			add_settings_error(
    				'privacy_action_email_retry',
    				'privacy_action_email_retry',
    				__( 'Confirmation request sent again successfully.' ),
    				'success'
    			);
    		}
    	} elseif ( isset( $_POST['action'] ) ) {
    		$action = ! empty( $_POST['action'] ) ? sanitize_key( wp_unslash( $_POST['action'] ) ) : '';

    		switch ( $action ) {
    			case 'add_export_personal_data_request':
    			case 'add_remove_personal_data_request':
    				check_admin_referer( 'personal-data-request' );

    				if ( ! isset( $_POST['type_of_action'], $_POST['username_or_email_for_privacy_request'] ) ) {
    					add_settings_error(
    						'action_type',
    						'action_type',
    						__( 'Invalid personal data action.' ),
    						'error'
    					);
    				}
    				$action_type               = sanitize_text_field( wp_unslash( $_POST['type_of_action'] ) );
    				$username_or_email_address = sanitize_text_field( wp_unslash( $_POST['username_or_email_for_privacy_request'] ) );
    				$email_address             = '';
    				$status                    = 'pending';

    				if ( ! isset( $_POST['send_confirmation_email'] ) ) {
    					$status = 'confirmed';
    				}

    				if ( ! in_array( $action_type, _wp_privacy_action_request_types(), true ) ) {
    					add_settings_error(
    						'action_type',
    						'action_type',
    						__( 'Invalid personal data action.' ),
    						'error'
    					);
    				}

    				if ( ! is_email( $username_or_email_address ) ) {
    					$user = get_user_by( 'login', $username_or_email_address );
    					if ( ! $user instanceof WP_User ) {
    						add_settings_error(
    							'username_or_email_for_privacy_request',
    							'username_or_email_for_privacy_request',
    							__( 'Unable to add this request. A valid email address or username must be supplied.' ),
    							'error'
    						);
    					} else {
    						$email_address = $user->user_email;
    					}
    				} else {
    					$email_address = $username_or_email_address;
    				}

    				if ( empty( $email_address ) ) {
    					break;
    				}

    				$request_id = wp_create_user_request( $email_address, $action_type, array(), $status );
    				$message    = '';

    				if ( is_wp_error( $request_id ) ) {
    					$message = $request_id->get_error_message();
    				} elseif ( ! $request_id ) {
    					$message = __( 'Unable to initiate confirmation request.' );
    				}

    				if ( $message ) {
    					add_settings_error(
    						'username_or_email_for_privacy_request',
    						'username_or_email_for_privacy_request',
    						$message,
    						'error'
    					);
    					break;
    				}

    				if ( 'pending' === $status ) {
    					wp_send_user_request( $request_id );

    					$message = __( 'Confirmation request initiated successfully.' );
    				} elseif ( 'confirmed' === $status ) {
    					$message = __( 'Request added successfully.' );
    				}

    				if ( $message ) {
    					add_settings_error(
    						'username_or_email_for_privacy_request',
    						'username_or_email_for_privacy_request',
    						$message,
    						'success'
    					);
    					break;
    				}
    		}
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/privacy-tools.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-admin/includes/privacy-tools.php#L73)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/privacy-tools.php#L73-L187)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/_wp_personal_data_handle_actions/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_create_user_request()](https://developer.wordpress.org/reference/functions/wp_create_user_request/)`wp-includes/user.php` |

Creates and logs a user request to perform a specific action.

  | 
| [wp_send_user_request()](https://developer.wordpress.org/reference/functions/wp_send_user_request/)`wp-includes/user.php` |

Send a confirmation request email to confirm an action.

  | 
| [_wp_privacy_action_request_types()](https://developer.wordpress.org/reference/functions/_wp_privacy_action_request_types/)`wp-includes/user.php` |

Gets all personal data request types.

  | 
| [_wp_privacy_resend_request()](https://developer.wordpress.org/reference/functions/_wp_privacy_resend_request/)`wp-admin/includes/privacy-tools.php` |

Resend an existing request and return the result.

  | 
| [add_settings_error()](https://developer.wordpress.org/reference/functions/add_settings_error/)`wp-admin/includes/template.php` |

Registers a settings error to be displayed to the user.

  | 
| [is_email()](https://developer.wordpress.org/reference/functions/is_email/)`wp-includes/formatting.php` |

Verifies that an email is valid.

  | 
| [check_admin_referer()](https://developer.wordpress.org/reference/functions/check_admin_referer/)`wp-includes/pluggable.php` |

Ensures intent by verifying that a user was referred from another admin page with the correct security nonce.

  | 
| [get_user_by()](https://developer.wordpress.org/reference/functions/get_user_by/)`wp-includes/pluggable.php` |

Retrieves user info by a given field.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [wp_unslash()](https://developer.wordpress.org/reference/functions/wp_unslash/)`wp-includes/formatting.php` |

Removes slashes from a string or recursively removes slashes from strings within an array.

  | 
| [sanitize_text_field()](https://developer.wordpress.org/reference/functions/sanitize_text_field/)`wp-includes/formatting.php` |

Sanitizes a string from user input or from the database.

  | 
| [sanitize_key()](https://developer.wordpress.org/reference/functions/sanitize_key/)`wp-includes/formatting.php` |

Sanitizes a string key.

  | 
| [absint()](https://developer.wordpress.org/reference/functions/absint/)`wp-includes/load.php` |

Converts a value to non-negative integer.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  |

[Show 9 more](https://developer.wordpress.org/reference/functions/_wp_personal_data_handle_actions/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/_wp_personal_data_handle_actions/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_wp_personal_data_handle_actions/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.9.6](https://developer.wordpress.org/reference/since/4.9.6/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_wp_personal_data_handle_actions%2F)
before being able to contribute a note or feedback.