WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/05/2021 03:48:59 PM (7 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/user.php

    r50165 r50230  
    39373937 *
    39383938 * @since 4.9.6
    3939  * @since 5.7.0 Added the `$send_confirmation_email` parameter.
     3939 * @since 5.7.0 Added the `$status` parameter.
    39403940 *
    39413941 * @param string $email_address           User email address. This can be the address of a registered
     
    39443944 * @param array  $request_data            Misc data you want to send with the verification request and pass
    39453945 *                                        to the actions once the request is confirmed.
    3946  * @param bool   $send_confirmation_email Optional. If false, the request status is set to 'Completed' directly.
    3947  *                                        Default true.
     3946 * @param string $status                  Optional request status (pending or confirmed). Default 'pending'.
    39483947 * @return int|WP_Error                   Returns the request ID if successful, or a WP_Error object on failure.
    39493948 */
    3950 function wp_create_user_request( $email_address = '', $action_name = '', $request_data = array(), $send_confirmation_email = true ) {
     3949function wp_create_user_request( $email_address = '', $action_name = '', $request_data = array(), $status = 'pending' ) {
    39513950    $email_address = sanitize_email( $email_address );
    39523951    $action_name   = sanitize_key( $action_name );
     
    39583957    if ( ! in_array( $action_name, _wp_privacy_action_request_types(), true ) ) {
    39593958        return new WP_Error( 'invalid_action', __( 'Invalid action name.' ) );
     3959    }
     3960
     3961    if ( ! in_array( $status, array( 'pending', 'confirmed' ), true ) ) {
     3962        return new WP_Error( 'invalid_status', __( 'Invalid request status.' ) );
    39603963    }
    39613964
     
    39813984    }
    39823985
    3983     if ( false !== $send_confirmation_email ) {
    3984         $status = 'request-pending';
    3985     } else {
    3986         $status = 'request-completed';
    3987     }
    3988 
    39893986    $request_id = wp_insert_post(
    39903987        array(
     
    39933990            'post_title'    => $email_address,
    39943991            'post_content'  => wp_json_encode( $request_data ),
    3995             'post_status'   => $status,
     3992            'post_status'   => 'request-' . $status,
    39963993            'post_type'     => 'user_request',
    39973994            'post_date'     => current_time( 'mysql', false ),
Note: See TracChangeset for help on using the changeset viewer.