Privacy: Rename the `$send_confirmation_email` parameter of `wp_create_user_request()` to `$status`, for clarity.
Follow-up to [50159], [50165]. Props xkon, TimothyBlynJacobs. Fixes #52430. See #43890. Built from https://develop.svn.wordpress.org/trunk@50230 git-svn-id: http://core.svn.wordpress.org/trunk@49891 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9cd08881ba
commit
a80f705d97
|
@ -111,10 +111,10 @@ function _wp_personal_data_handle_actions() {
|
|||
$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 = '';
|
||||
$send_confirmation_email = true;
|
||||
$status = 'pending';
|
||||
|
||||
if ( ! isset( $_POST['send_confirmation_email'] ) ) {
|
||||
$send_confirmation_email = false;
|
||||
$status = 'confirmed';
|
||||
}
|
||||
|
||||
if ( ! in_array( $action_type, _wp_privacy_action_request_types(), true ) ) {
|
||||
|
@ -146,37 +146,42 @@ function _wp_personal_data_handle_actions() {
|
|||
break;
|
||||
}
|
||||
|
||||
$request_id = wp_create_user_request( $email_address, $action_type, array(), $send_confirmation_email );
|
||||
$request_id = wp_create_user_request( $email_address, $action_type, array(), $status );
|
||||
$message = '';
|
||||
|
||||
if ( is_wp_error( $request_id ) ) {
|
||||
add_settings_error(
|
||||
'username_or_email_for_privacy_request',
|
||||
'username_or_email_for_privacy_request',
|
||||
$request_id->get_error_message(),
|
||||
'error'
|
||||
);
|
||||
break;
|
||||
$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',
|
||||
__( 'Unable to initiate confirmation request.' ),
|
||||
$message,
|
||||
'error'
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $send_confirmation_email ) {
|
||||
if ( 'pending' === $status ) {
|
||||
wp_send_user_request( $request_id );
|
||||
|
||||
$message = __( 'Confirmation request initiated successfully.' );
|
||||
} elseif ( 'confirmed' === $status ) {
|
||||
$message = __( 'Request added successfully.' );
|
||||
}
|
||||
|
||||
add_settings_error(
|
||||
'username_or_email_for_privacy_request',
|
||||
'username_or_email_for_privacy_request',
|
||||
__( 'Confirmation request initiated successfully.' ),
|
||||
'success'
|
||||
);
|
||||
break;
|
||||
if ( $message ) {
|
||||
add_settings_error(
|
||||
'username_or_email_for_privacy_request',
|
||||
'username_or_email_for_privacy_request',
|
||||
$message,
|
||||
'success'
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3936,18 +3936,17 @@ function _wp_privacy_account_request_confirmed_message( $request_id ) {
|
|||
* users on the site, or guests without a user account.
|
||||
*
|
||||
* @since 4.9.6
|
||||
* @since 5.7.0 Added the `$send_confirmation_email` parameter.
|
||||
* @since 5.7.0 Added the `$status` parameter.
|
||||
*
|
||||
* @param string $email_address User email address. This can be the address of a registered
|
||||
* or non-registered user.
|
||||
* @param string $action_name Name of the action that is being confirmed. Required.
|
||||
* @param array $request_data Misc data you want to send with the verification request and pass
|
||||
* to the actions once the request is confirmed.
|
||||
* @param bool $send_confirmation_email Optional. If false, the request status is set to 'Completed' directly.
|
||||
* Default true.
|
||||
* @param string $status Optional request status (pending or confirmed). Default 'pending'.
|
||||
* @return int|WP_Error Returns the request ID if successful, or a WP_Error object on failure.
|
||||
*/
|
||||
function wp_create_user_request( $email_address = '', $action_name = '', $request_data = array(), $send_confirmation_email = true ) {
|
||||
function wp_create_user_request( $email_address = '', $action_name = '', $request_data = array(), $status = 'pending' ) {
|
||||
$email_address = sanitize_email( $email_address );
|
||||
$action_name = sanitize_key( $action_name );
|
||||
|
||||
|
@ -3959,6 +3958,10 @@ function wp_create_user_request( $email_address = '', $action_name = '', $reques
|
|||
return new WP_Error( 'invalid_action', __( 'Invalid action name.' ) );
|
||||
}
|
||||
|
||||
if ( ! in_array( $status, array( 'pending', 'confirmed' ), true ) ) {
|
||||
return new WP_Error( 'invalid_status', __( 'Invalid request status.' ) );
|
||||
}
|
||||
|
||||
$user = get_user_by( 'email', $email_address );
|
||||
$user_id = $user && ! is_wp_error( $user ) ? $user->ID : 0;
|
||||
|
||||
|
@ -3980,19 +3983,13 @@ function wp_create_user_request( $email_address = '', $action_name = '', $reques
|
|||
return new WP_Error( 'duplicate_request', __( 'An incomplete personal data request for this email address already exists.' ) );
|
||||
}
|
||||
|
||||
if ( false !== $send_confirmation_email ) {
|
||||
$status = 'request-pending';
|
||||
} else {
|
||||
$status = 'request-completed';
|
||||
}
|
||||
|
||||
$request_id = wp_insert_post(
|
||||
array(
|
||||
'post_author' => $user_id,
|
||||
'post_name' => $action_name,
|
||||
'post_title' => $email_address,
|
||||
'post_content' => wp_json_encode( $request_data ),
|
||||
'post_status' => $status,
|
||||
'post_status' => 'request-' . $status,
|
||||
'post_type' => 'user_request',
|
||||
'post_date' => current_time( 'mysql', false ),
|
||||
'post_date_gmt' => current_time( 'mysql', true ),
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.7-beta1-50229';
|
||||
$wp_version = '5.7-beta1-50230';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue