update_user_status()
update_user_status( int $id, string $pref, int $value, …
update_user_status( int $id, string $pref, int $value, null $deprecated = null )
更新数据库中用户的状态。
Update the status of a user in the database.
目录锚点:#说明#参数#源码#笔记
说明(Description)
以前在core中用于在Multisite中将用户标记为垃圾邮件或“ham”(不是垃圾邮件)。另请参阅wp_update_user()
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $id | (int) | 用户ID。 |
| $pref | (string) | wp_users表中要在中更新用户状态的列(可能是用户的状态、垃圾邮件或已删除)。 |
| $value | (int) | 用户的新状态。 |
| $deprecated | (null) | 自3.0.2起已弃用,不应使用。 |
源码(Source)
/**
* Update the status of a user in the database.
*
* Used in core to mark a user as spam or "ham" (not spam) in Multisite.
*
* @since 3.0.0
*
* @global wpdb $wpdb
*
* @param int $id The user ID.
* @param string $pref The column in the wp_users table to update the user's status
* in (presumably user_status, spam, or deleted).
* @param int $value The new status for the user.
* @param null $deprecated Deprecated as of 3.0.2 and should not be used.
* @return int The initially passed $value.
*/
function update_user_status( $id, $pref, $value, $deprecated = null ) {
global $wpdb;
if ( null !== $deprecated )
_deprecated_argument( __FUNCTION__, '3.1' );
$wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );
$user = new WP_User( $id );
clean_user_cache( $user );
if ( $pref == 'spam' ) {
if ( $value == 1 ) {
/**
* Fires after the user is marked as a SPAM user.
*
* @since 3.0.0
*
* @param int $id ID of the user marked as SPAM.
*/
do_action( 'make_spam_user', $id );
} else {
/**
* Fires after the user is marked as a HAM user. Opposite of SPAM.
*
* @since 3.0.0
*
* @param int $id ID of the user marked as HAM.
*/
do_action( 'make_ham_user', $id );
}
}
return $value;
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 5.3.0 | wp-includes/ms-deprecated.php | 7 | 11 |
笔记(Notes)
基本示例
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。


还没有任何评论,赶紧来占个楼吧!