^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 5年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云1核2g仅需102元/年,今日10点开抢

wordpress函数delete_usermeta()用法示例

Warning: This function has been deprecated. Use delete_user_meta() instead.

delete_usermeta( int $user_id,  string $meta_key,  mixed $meta_value = '' )

Remove user meta data.


描述


参数

$user_id

(int)
(Required)
User ID.

$meta_key

(string)
(Required)
Metadata key.

$meta_value

(mixed)
(Optional)
Metadata value.

Default value: ”


返回值

(bool) True deletion completed and false if user_id is not a number.


源代码

File: wp-includes/deprecated.php

function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) {
	_deprecated_function( __FUNCTION__, '3.0.0', 'delete_user_meta()' );
	global $wpdb;
	if ( !is_numeric( $user_id ) )
		return false;
	$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);

	if ( is_array($meta_value) || is_object($meta_value) )
		$meta_value = serialize($meta_value);
	$meta_value = trim( $meta_value );

	$cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );

	if ( $cur && $cur->umeta_id )
		do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );

	if ( ! empty($meta_value) )
		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) );
	else
		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );

	clean_user_cache( $user_id );
	wp_cache_delete( $user_id, 'user_meta' );

	if ( $cur && $cur->umeta_id )
		do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );

	return true;
}

更新日志

Version 描述
3.0.0 Use delete_user_meta()
2.0.0 Introduced.

相关函数

Uses

  • wp-includes/cache.php:
    wp_cache_delete()
  • wp-includes/functions.php:
    _deprecated_function()
  • wp-includes/plugin.php:
    do_action()
  • wp-includes/user.php:
    clean_user_cache()
  • wp-includes/wp-db.php:
    wpdb::get_row()
  • wp-includes/wp-db.php:
    wpdb::query()
  • wp-includes/wp-db.php:
    wpdb::prepare()
  • Show 2 more uses
    Hide more uses


Used By

  • wp-includes/deprecated.php:
    update_usermeta()

User Contributed Notes

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈