Validates a user request by comparing the key with the request’s key.
Parameters
$request_id
stringrequired- ID of the request being confirmed.
$key
stringrequired- Provided key to validate.
Source
* @type string $description Description of the action being performed so the user knows what the email is for.
* @type string $confirm_url The link to click on to confirm the account action.
* @type string $sitename The site name sending the mail.
* @type string $siteurl The site URL sending the mail.
* }
*/
$headers = apply_filters( 'user_request_action_email_headers', $headers, $subject, $content, $request_id, $email_data );
$email_sent = wp_mail( $email_data['email'], $subject, $content, $headers );
if ( $switched_locale ) {
restore_previous_locale();
}
if ( ! $email_sent ) {
return new WP_Error( 'privacy_email_error', __( 'Unable to send personal data export confirmation email.' ) );
}
return true;
}
/**
* Returns a confirmation key for a user action and stores the hashed version for future comparison.
*
* @since 4.9.6
*
* @param int $request_id Request ID.
* @return string Confirmation key.
*/
function wp_generate_user_request_key( $request_id ) {
// Generate something random for a confirmation key.
$key = wp_generate_password( 20, false );
// Save the key, hashed.
wp_update_post(
array(
'ID' => $request_id,
'post_status' => 'request-pending',
'post_password' => wp_fast_hash( $key ),
)
);
return $key;
}
Changelog
Version | Description |
---|---|
4.9.6 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.