In `wp_insert_user()`, add a filter: `insert_user_meta`, to filter a user's meta values and keys before the user is created or updated.
Props tharsheblows, chriscct7, DrewAPicture. Fixes #31549. Built from https://develop.svn.wordpress.org/trunk@33708 git-svn-id: http://core.svn.wordpress.org/trunk@33675 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5510b519f5
commit
c192d90fa1
|
@ -2063,6 +2063,32 @@ function wp_insert_user( $userdata ) {
|
||||||
|
|
||||||
$user = new WP_User( $user_id );
|
$user = new WP_User( $user_id );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter a user's meta 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.4.0
|
||||||
|
*
|
||||||
|
* @param array $meta {
|
||||||
|
* Default meta values and keys for the user.
|
||||||
|
*
|
||||||
|
* @type string $nickname The user's nickname. Default is the 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 WP_User $user User object.
|
||||||
|
*/
|
||||||
|
$meta = apply_filters( 'insert_user_meta', $meta, $user );
|
||||||
|
|
||||||
// Update user meta.
|
// Update user meta.
|
||||||
foreach ( $meta as $key => $value ) {
|
foreach ( $meta as $key => $value ) {
|
||||||
update_user_meta( $user_id, $key, $value );
|
update_user_meta( $user_id, $key, $value );
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-33707';
|
$wp_version = '4.4-alpha-33708';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue