[wp-trac] [WordPress Trac] #39829: Missing Filter before user is created within "wp_insert_user" function

WordPress Trac noreply at wordpress.org
Tue May 16 04:18:04 UTC 2017


#39829: Missing Filter before user is created within "wp_insert_user" function
-------------------------+------------------------------
 Reporter:  jaschaio     |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Users        |     Version:  4.7.2
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+------------------------------

Comment (by sc0ttkclark):

 I also am +1 on a filter before the user is created OR updated, just after
 the `$data` var is set.

 Something like this?

 {{{
         $data = wp_unslash( $compacted );

         /**
          * Filters a user's data values and keys before the user is
 created or updated.
          *
          * Does not include contact methods. These are added using
 `wp_get_user_contact_methods( $user )`.
          *
          * @since 4.8
          *
          * @param array $data {
          *     Default data values and keys for the user.
          *
          *     @type string $user_pass       The user's password.
          *     @type string $user_email      The user's email.
          *     @type string $user_url        The user's url.
          *     @type string $user_nicename   The user's nicename.
          *     @type string $display_name    The user's display name.
          *     @type string $user_registered The user's registration date.
          * }
          * @param array $where {
          *     Values and keys used for identifying the user being
 inserted or updated.
          *
          *     @type int    $ID         The user's ID.
          *     @type string $user_login The user's login.
          * }
          * @param array $meta {
          *     Default meta values and keys for the user.
          *
          *     @type string   $nickname             The user's nickname.
 Default is the user's username.
          *     @type string   $first_name           The user's first name.
          *     @type string   $last_name            The user's last name.
          *     @type string   $description          The user's
 description.
          *     @type bool     $rich_editing         Whether to enable the
 rich-editor for the user. False if not empty.
          *     @type bool     $comment_shortcuts    Whether to enable
 keyboard shortcuts for the user. Default false.
          *     @type string   $admin_color          The color scheme for a
 user's admin screen. Default 'fresh'.
          *     @type int|bool $use_ssl              Whether to force SSL
 on the user's admin area. 0|false if SSL is
          *                                          not forced.
          *     @type bool     $show_admin_bar_front Whether to show the
 admin bar on the front end for the user.
          *                                          Default true.
          * }
          * @param bool  $update Whether the user is being updated rather
 than created.
          */
         $data = apply_filters( 'insert_user_data', $data, compact( 'ID',
 'user_login' ), $meta, $update );
 }}}

 I think we should follow up with an additional ticket at some point that
 fixes the text of the `insert_user_meta` filter does not describe as
 "before the user is created or updated" -- it should actually be "after
 the user has been created or updated". Right now, the hook description is
 problematic and misinforming to developers.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39829#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list