wp_delete_user()删除一个用户,并转移文章给其他用户

目录

描述

译文

移除用户,并选择性地将文章和链接重新分配给另一个用户。

若未将$reassign参数分配给用户编号,则原用户的所有文章将被删除。文章被删除或重新分配后,运行'delete_user'动作,该动作传递将被删除的用户编号。用户编号下的用户meta也将被删除。

原文

Remove user and optionally reassign posts and links to another user.

If the $reassign parameter is not assigned to a User ID, then all posts will be deleted of that user. The action 'delete_user' that is passed the User ID being deleted will be run after the posts are either reassigned or deleted. The user meta will also be deleted that are for that User ID.

wp_delete_user() 描述

用法

<?php wp_delete_user$id$reassign ); ?>

wp_delete_user() 用法

参数

$id

(integer) (必填) User ID.

默认值: None

$reassign

(integer) (可选) Reassign posts and links to new User ID.

默认值: null

wp_delete_user() 参数

返回值

(boolean) 

True when finished.

wp_delete_user() 返回值

示例

Allow users to terminate their user accounts.

wp_delete_user() 示例

注意

  • If you wish to use this function in a plugin then you must include the ./wp-admin/includes/user.php file in your plugin function, else it will throw a 'call to undefined function' error
  • 使用到 global: (object) $wpdb
  • This is an Admin function.
  • 使用到: do_action() 调用 'deleted_user' hook

wp_delete_user() 注意

历史

添加于 版本: 2.0

wp_delete_user() 历史

源文件

wp_delete_user() 函数的代码位于 wp-admin/includes/user.php.

wp_delete_user() 源文件