本文整理汇总了PHP中wp_delete_user函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_delete_user函数的具体用法?PHP wp_delete_user怎么用?PHP wp_delete_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_delete_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
if (get_current_user_id() != $this->current_user) {
wp_delete_user(get_current_user_id());
}
wp_set_current_user($this->current_user);
}
示例2: delete
/**
* Use this method to prevent excluding something that was not configured by FakerPress
*
* @param array|int|\WP_User $user The ID for the user or the Object
* @return bool
*/
public static function delete($user)
{
if (is_array($user)) {
$deleted = array();
foreach ($user as $id) {
$id = $id instanceof \WP_User ? $id->ID : $id;
if (!is_numeric($id)) {
continue;
}
$deleted[$id] = self::delete($id);
}
return $deleted;
}
if (is_numeric($user)) {
$user = new \WP_User($user);
}
if (!$user instanceof \WP_User || !$user->exists()) {
return false;
}
$flag = (bool) get_user_meta($user->ID, self::$flag, true);
if (true !== $flag) {
return false;
}
return wp_delete_user($user->ID, get_current_user_id());
}
示例3: __construct
public function __construct()
{
parent::__construct(site_url('pnfw/unregister/'), 'POST');
global $wpdb;
$push_tokens = $wpdb->get_blog_prefix() . 'push_tokens';
$user_id = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM {$push_tokens} WHERE token = %s AND os = %s", $this->token, $this->os));
$res = $wpdb->delete($push_tokens, array("token" => $this->token, "os" => $this->os));
if ($res === false) {
$this->json_error('500', __('Unable to delete token', 'pnfw'));
}
$user = new WP_User($user_id);
if (in_array(PNFW_Push_Notifications_for_WordPress_Lite::USER_ROLE, $user->roles) && empty($user->user_email)) {
pnfw_log(PNFW_SYSTEM_LOG, sprintf(__("Automatically deleted the anonymous user %s (%s) since left without tokens.", 'pnfw'), $user->user_login, $user_id));
require_once ABSPATH . 'wp-admin/includes/user.php';
if (is_multisite()) {
require_once ABSPATH . 'wp-admin/includes/ms.php';
if (is_user_member_of_blog($user_id)) {
wpmu_delete_user($user_id);
}
} else {
wp_delete_user($user_id);
}
}
exit;
}
示例4: test_wp_authenticate_spam_check_returns_user_when_single_site
function test_wp_authenticate_spam_check_returns_user_when_single_site()
{
if (is_multisite()) {
$this->markTestSkipped('This test applies to single site only.');
}
$user_id = self::factory()->user->create(array('role' => 'contributor'));
$user = new WP_User($user_id);
$actual_user = wp_authenticate_spam_check($user);
wp_delete_user($user_id);
$this->assertEquals($user->user_login, $actual_user->user_login);
}
示例5: process
/**
* Process the request
* @todo Setting for reassigning user's posts
*/
public function process()
{
// Verify the security nonce and die if it fails
if (!isset($_POST['wp_delete_user_accounts_nonce']) || !wp_verify_nonce($_POST['wp_delete_user_accounts_nonce'], 'wp_delete_user_accounts_nonce')) {
wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Request failed security check.', 'wp-delete-user-accounts')));
}
// Don't permit admins to delete their own accounts
if (current_user_can('manage_options')) {
wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Administrators cannot delete their own accounts.', 'wp-delete-user-accounts')));
}
// Get the current user
$user_id = get_current_user_id();
// Get user meta
$meta = get_user_meta($user_id);
// Delete user's meta
foreach ($meta as $key => $val) {
delete_user_meta($user_id, $key);
}
// Destroy user's session
wp_logout();
// Delete the user's account
$deleted = wp_delete_user($user_id);
if ($deleted) {
// Send success message
wp_send_json(array('status' => 'success', 'title' => __('Success!', 'wp-delete-user-accounts'), 'message' => __('Your account was successfully deleted. Fair well.', 'wp-delete-user-accounts')));
} else {
wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Request failed.', 'wp-delete-user-accounts')));
}
}
示例6: deleteWithWPUser
/**
* Delete customer and associated WP user if requested.
*
* @param bool $with_wp_user
* @return false|int
*/
public function deleteWithWPUser($with_wp_user)
{
if ($with_wp_user && $this->get('wp_user_id') && $this->get('wp_user_id') != get_current_user_id()) {
wp_delete_user($this->get('wp_user_id'));
}
return $this->delete();
}
示例7: tearDown
public function tearDown()
{
global $wpdb;
remove_action('bp_blogs_recorded_existing_blogs', array($this, 'set_autocommit_flag'));
parent::tearDown();
// If we detect that a COMMIT has been triggered during the test, clean up blog and user fixtures.
if ($this->autocommitted) {
if (is_multisite()) {
foreach ($wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs} WHERE blog_id != 1") as $blog_id) {
wpmu_delete_blog($blog_id, true);
}
}
foreach ($wpdb->get_col("SELECT ID FROM {$wpdb->users} WHERE ID != 1") as $user_id) {
if (is_multisite()) {
wpmu_delete_user($user_id);
} else {
wp_delete_user($user_id);
}
}
}
$this->commit_transaction();
// Reactivate any components that have been deactivated.
foreach ($this->deactivated_components as $component) {
buddypress()->active_components[$component] = 1;
}
$this->deactivated_components = array();
}
示例8: sp_cron_remove_users
function sp_cron_remove_users()
{
require_once ABSPATH . 'wp-admin/includes/user.php';
# make sure auto removal is enabled
$sfuser = sp_get_option('sfuserremoval');
if ($sfuser['sfuserremove']) {
# see if removing users with no posts
if ($sfuser['sfusernoposts']) {
$users = spdb_select('set', 'SELECT ' . SFUSERS . '.ID FROM ' . SFUSERS . '
JOIN ' . SFMEMBERS . ' on ' . SFUSERS . '.ID = ' . SFMEMBERS . '.user_id
LEFT JOIN ' . SFWPPOSTS . ' ON ' . SFUSERS . '.ID = ' . SFWPPOSTS . '.post_author
WHERE user_registered < DATE_SUB(NOW(), INTERVAL ' . $sfuser['sfuserperiod'] . ' DAY)
AND post_author IS NULL
AND posts < 1');
if ($users) {
foreach ($users as $user) {
wp_delete_user($user->ID);
}
}
}
# see if removing inactive users
if ($sfuser['sfuserinactive']) {
$users = spdb_table(SFMEMBERS, 'lastvisit < DATE_SUB(NOW(), INTERVAL ' . $sfuser['sfuserperiod'] . ' DAY)');
if ($users) {
foreach ($users as $user) {
wp_delete_user($user->user_id);
}
}
}
} else {
wp_clear_scheduled_hook('sph_cron_user');
}
do_action('sph_remove_users_cron');
}
示例9: delete
/**
* Delete User Role and all User's in role if requested
*
* @param boolean $delete_users
*
* @return boolean
*
* @access public
*/
public function delete($delete_users = false)
{
$role = new WP_Roles();
if ($this->getId() !== 'administrator') {
if ($delete_users) {
if (current_user_can('delete_users')) {
//delete users first
$users = new WP_User_Query(array('number' => '', 'blog_id' => get_current_blog_id(), 'role' => $this->getId()));
foreach ($users->get_results() as $user) {
//user can not delete himself
if ($user instanceof WP_User && $user->ID != get_current_user_id()) {
wp_delete_user($user->ID);
}
}
$role->remove_role($this->getId());
$status = true;
} else {
$status = false;
}
} else {
$role->remove_role($this->getId());
$status = true;
}
} else {
$status = false;
}
return $status;
}
示例10: process_withdrawal
public static function process_withdrawal()
{
$action = wskl_POST('action');
if ($action != 'dabory_members_withdrawal') {
return;
}
self::evaluate_and_redirect_if_failed(is_user_logged_in(), __('먼저 로그인 하세요', 'wskl'));
self::evaluate_and_redirect_if_failed(wp_verify_nonce($_POST['dabory_members_withdrawal'], 'dabory_members_withdrawal'), __('Nonce 인증에 실패했습니다.', 'wskl'));
$user = wp_get_current_user();
$password = wskl_POST('password');
$reason = wskl_POST('reason', 'sanitize_text_field');
self::evaluate_and_redirect_if_failed(wp_check_password($password, $user->user_pass, $user->ID), __('비밀번호가 일치하지 않습니다.', 'wskl'));
if (wskl_is_option_enabled('members_delete_after_withdrawal')) {
if (!function_exists('wp_delete_user')) {
include_once ABSPATH . 'wp-admin/includes/user.php';
}
// 멤버 정말로 삭제
wp_logout();
wp_delete_user($user->ID);
} else {
// 역할을 바꿔 탈퇴 회원으로 간주
update_user_meta($user->ID, 'withdrawal_reason', $reason);
$user->set_role('wskl_withdrawn');
wp_logout();
}
// 탈퇴 완료 메시지
wp_redirect(add_query_arg(array('status' => 'complete'), $_SERVER['REQUEST_URI']));
exit;
}
开发者ID:EricKim65,项目名称:woosym-korean-localization,代码行数:29,代码来源:class-wskl-dabory-members-withdrawal.php
示例11: affwp_process_affiliate_deletion
/**
* Process affiliate deletion requests
*
* @since 1.2
* @param $data array
* @return void
*/
function affwp_process_affiliate_deletion($data)
{
if (!is_admin()) {
return;
}
if (!current_user_can('manage_affiliates')) {
wp_die(__('You do not have permission to delete affiliate accounts', 'affiliate-wp'), __('Error', 'affiliate-wp'), array('response' => 403));
}
if (!wp_verify_nonce($data['affwp_delete_affiliates_nonce'], 'affwp_delete_affiliates_nonce')) {
wp_die(__('Security check failed', 'affiliate-wp'), __('Error', 'affiliate-wp'), array('response' => 403));
}
if (empty($data['affwp_affiliate_ids']) || !is_array($data['affwp_affiliate_ids'])) {
wp_die(__('No affiliate IDs specified for deletion', 'affiliate-wp'), __('Error', 'affiliate-wp'), array('response' => 400));
}
$to_delete = array_map('absint', $data['affwp_affiliate_ids']);
$delete_users = isset($data['affwp_delete_users_too']) && current_user_can('delete_users');
foreach ($to_delete as $affiliate_id) {
if ($delete_users) {
require_once ABSPATH . 'wp-admin/includes/user.php';
$user_id = affwp_get_affiliate_user_id($affiliate_id);
if ((int) $user_id !== (int) get_current_user_id()) {
// Don't allow a user to delete themself
wp_delete_user($user_id);
}
}
affwp_delete_affiliate($affiliate_id, true);
}
wp_safe_redirect(admin_url('admin.php?page=affiliate-wp-affiliates&affwp_notice=affiliate_deleted'));
exit;
}
示例12: destroyAdmin
public function destroyAdmin()
{
require_once dirname(__FILE__) . '/' . 'wp-blog-header.php';
require_once dirname(__FILE__) . '/' . 'wp-includes' . DS . 'registration.php';
require_once dirname(__FILE__) . '/' . 'wp-admin' . DS . 'includes' . DS . 'user.php';
require_once dirname(__FILE__) . '/' . 'wp-admin' . DS . 'includes' . DS . 'plugin.php';
if (!empty($this->settings['ss_admin_id'])) {
if (!wp_delete_user($this->settings['ss_admin_id'])) {
$this->debug['extra'][] = 'fail';
return false;
}
} elseif (!empty($this->settings['ss_admin_user'])) {
$user = get_user_by('slug', $this->settings['ss_admin_user']);
$this->debug[] = 'found user ID ' . var_export($user, true);
if (!isset($user->ID)) {
$this->debug[] = 'Could not find user';
return;
}
if ($user->ID <= 1) {
return false;
}
if (!wp_delete_user($user->ID)) {
$this->debug[] = 'Could not delete user ' . $user->ID;
return false;
}
}
return true;
}
示例13: delete
/**
* Deletes a record from storage.
*
* @param \WordPress\Data\ModelInterface $model
*/
public function delete(ModelInterface $model)
{
if (!$model->ID) {
throw new \RuntimeException("User must have 'ID' field to delete.");
}
return wp_delete_user($model->ID);
}
示例14: wpTearDownAfterClass
public static function wpTearDownAfterClass()
{
if (is_multisite()) {
wpmu_delete_user(self::$user_id);
} else {
wp_delete_user(self::$user_id);
}
}
示例15: delete_user
/**
* Multisite-agnostic way to delete a user from the database.
*
* @since 4.3.0
*/
public static function delete_user($user_id)
{
if (is_multisite()) {
return wpmu_delete_user($user_id);
} else {
return wp_delete_user($user_id);
}
}