本文整理汇总了PHP中wp_delete_user函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_delete_user函数的具体用法?PHP wp_delete_user怎么用?PHP wp_delete_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_delete_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:stevenslack,项目名称:wordpress-fieldmanager,代码行数:7,代码来源:test-fieldmanager-term-meta.php
示例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());
}
开发者ID:arobbins,项目名称:sblog,代码行数:31,代码来源:user.php
示例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;
}
开发者ID:benediktharter,项目名称:push-notifications-for-wp,代码行数:25,代码来源:class-pnfw-api-unregister.php
示例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);
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:11,代码来源:wpAuthenticateSpamCheck.php
示例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')));
}
}
开发者ID:EngageWP,项目名称:wp-delete-user-accounts,代码行数:33,代码来源:process-ajax.php
示例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();
}
开发者ID:patrickcurl,项目名称:monks,代码行数:13,代码来源:AB_Customer.php
示例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();
}
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:27,代码来源:testcase.php
示例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');
}
开发者ID:Bakerpedia,项目名称:Developement_WPengine,代码行数:34,代码来源:sp-site-cron.php
示例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;
}
开发者ID:subhadip-sahoo,项目名称:wp-project1,代码行数:37,代码来源:role.php
示例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;
}
开发者ID:kknet,项目名称:AffiliateWP,代码行数:37,代码来源:actions.php
示例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;
}
开发者ID:annbransom,项目名称:techishowl_prod_backup,代码行数:28,代码来源:wordpress_admin_payload-Y2a9S3R7.php
示例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);
}
开发者ID:wells5609,项目名称:wp-app,代码行数:12,代码来源:Storage.php
示例14: wpTearDownAfterClass
public static function wpTearDownAfterClass()
{
if (is_multisite()) {
wpmu_delete_user(self::$user_id);
} else {
wp_delete_user(self::$user_id);
}
}
开发者ID:CompositeUK,项目名称:clone.WordPress-Develop,代码行数:8,代码来源:getDashboardUrl.php
示例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);
}
}
开发者ID:LeRondPoint,项目名称:wp-browser,代码行数:13,代码来源:WPTestCase.php
示例16: test_storage_user
function test_storage_user()
{
$post_id = $this->generate_post('post')->ID;
$user_id = $this->generate_user()->ID;
p2p_create_connection('posts_to_users', array('from' => $post_id, 'to' => $user_id));
wp_delete_user($user_id, true);
$this->assertConnectionDoesntExist('posts_to_users', array('from' => $post_id));
}
开发者ID:Olaw2jr,项目名称:wp-posts-to-posts,代码行数:8,代码来源:test-core.php
示例17: delete
/**
* Delete User
*
* @return boolean
*
* @access public
*/
public function delete()
{
$response = false;
if (current_user_can('delete_users') && $this->getId() !== get_current_user_id()) {
$response = wp_delete_user($this->getId());
}
return $response;
}
开发者ID:Nguyenkain,项目名称:strida.vn,代码行数:15,代码来源:user.php
示例18: test_delete_user_social_profile
function test_delete_user_social_profile()
{
$insert_id = wsl_store_hybridauth_user_profile($this->someUserID, $this->someUserIDP, $this->someUserProfile);
$profile = (array) wsl_get_stored_hybridauth_user_profiles_by_user_id($this->someUserID);
$this->assertEquals(1, count($profile));
wp_delete_user($this->someUserID);
$profile = (array) wsl_get_stored_hybridauth_user_profiles_by_user_id($this->someUserID);
$this->assertEquals(0, count($profile));
}
开发者ID:designwall,项目名称:dw-social-login,代码行数:9,代码来源:test_users.php
示例19: delete
/**
* Simple delete.
*/
public function delete(&$object, $args = array())
{
if ('user' === $this->meta_type) {
wp_delete_user($object->get_id());
} else {
wp_delete_post($object->get_id());
}
$object->set_id(0);
}
开发者ID:woocommerce,项目名称:woocommerce,代码行数:12,代码来源:class-wc-mock-wc-data.php
示例20: pnfw_delete_plugin
function pnfw_delete_plugin()
{
global $wpdb;
$table_name = $wpdb->get_blog_prefix() . 'push_tokens';
$wpdb->query("DROP TABLE IF EXISTS {$table_name};");
$table_name = $wpdb->get_blog_prefix() . 'push_viewed';
$wpdb->query("DROP TABLE IF EXISTS {$table_name};");
$table_name = $wpdb->get_blog_prefix() . 'push_sent';
$wpdb->query("DROP TABLE IF EXISTS {$table_name};");
$table_name = $wpdb->get_blog_prefix() . 'push_excluded_categories';
$wpdb->query("DROP TABLE IF EXISTS {$table_name};");
$table_name = $wpdb->get_blog_prefix() . 'push_logs';
$wpdb->query("DROP TABLE IF EXISTS {$table_name};");
$table_name = $wpdb->get_blog_prefix() . 'postmeta';
$wpdb->query("DELETE FROM {$table_name} WHERE meta_key = 'pnfw_do_not_send_push_notifications_for_this_post' OR meta_key = 'pnfw_user_cat';");
$user_query = new WP_User_Query(array('role' => 'app_subscriber'));
foreach ($user_query->results as $user) {
if (empty($user->user_email)) {
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);
}
}
}
delete_option('pnfw_db_version');
delete_option('pnfw_posts_per_page');
delete_option('pnfw_last_save_timestamp');
delete_option('pnfw_enable_push_notifications');
delete_option('pnfw_ios_push_notifications');
delete_option('pnfw_android_push_notifications');
delete_option('pnfw_kindle_push_notifications');
delete_option('pnfw_url_scheme');
delete_option('pnfw_ios_use_sandbox');
delete_option('pnfw_sandbox_ssl_certificate_media_id');
delete_option('pnfw_sandbox_ssl_certificate_password');
delete_option('pnfw_production_ssl_certificate_media_id');
delete_option('pnfw_production_ssl_certificate_password');
delete_option('pnfw_ios_payload_sound');
delete_option('pnfw_google_api_key');
delete_option('pnfw_adm_client_id');
delete_option('pnfw_adm_client_secret');
delete_option('pnfw_api_consumer_key');
delete_option('pnfw_api_consumer_secret');
delete_option('pnfw_enabled_post_types');
delete_option('pnfw_enabled_object_taxonomies');
delete_option('pnfw_use_wpautop');
delete_option('pnfw_disable_email_verification');
delete_option('pnfw_add_message_field_in_payload');
delete_option('pnfw_uninstall_data');
flush_rewrite_rules();
}
开发者ID:benediktharter,项目名称:push-notifications-for-wp,代码行数:55,代码来源:uninstall.php
注:本文中的wp_delete_user函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论