mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Users: add __unset to WP_User.
Adds unit tests. Props johnjamesjacoby, MikeHansenMe, wonderboymusic. Fixes #20043. git-svn-id: https://develop.svn.wordpress.org/trunk@34380 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -324,6 +324,26 @@ class WP_User {
|
||||
$this->data->$key = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method for unsetting a certain custom field
|
||||
*
|
||||
* @since 4.4.0
|
||||
*/
|
||||
function __unset( $key ) {
|
||||
if ( 'id' == $key ) {
|
||||
_deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) );
|
||||
$key = 'ID';
|
||||
}
|
||||
|
||||
if ( isset( $this->data->$key ) ) {
|
||||
unset( $this->data->$key );
|
||||
}
|
||||
|
||||
if ( isset( self::$back_compat_keys[ $key ] ) ) {
|
||||
unset( self::$back_compat_keys[ $key ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user exists in the database.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user