本文整理汇总了PHP中wpmu_delete_user函数的典型用法代码示例。如果您正苦于以下问题:PHP wpmu_delete_user函数的具体用法?PHP wpmu_delete_user怎么用?PHP wpmu_delete_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpmu_delete_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __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
示例2: 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
示例3: 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
示例4: 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
示例5: 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
示例6: test_author_queried_object_fix
/**
* On author pages, the queried object should only be set
* to a user that's not a member of the blog if they
* have at least one published post. This matches core behavior.
*
* @see https://core.trac.wordpress.org/changeset/27290
*/
function test_author_queried_object_fix()
{
global $wp_rewrite, $coauthors_plus;
/**
* Set up
*/
$author1 = $this->factory->user->create(array('user_login' => 'msauthor1'));
$author2 = $this->factory->user->create(array('user_login' => 'msauthor2'));
$blog2 = $this->factory->blog->create(array('user_id' => $author1));
switch_to_blog($blog2);
$wp_rewrite->init();
$blog2_post1 = $this->factory->post->create(array('post_status' => 'publish', 'post_content' => rand_str(), 'post_title' => rand_str(), 'post_author' => $author1));
/**
* Author 1 is an author on the blog
*/
$this->go_to(get_author_posts_url($author1));
$this->assertQueryTrue('is_author', 'is_archive');
/**
* Author 2 is not yet an author on the blog
*/
$this->go_to(get_author_posts_url($author2));
$this->assertQueryTrue('is_404');
// Add the user to the blog
add_user_to_blog($blog2, $author2, 'author');
/**
* Author 2 is now on the blog, but not yet published
*/
$this->go_to(get_author_posts_url($author2));
$this->assertQueryTrue('is_author', 'is_archive');
// Add the user as an author on the original post
$author2_obj = get_user_by('id', $author2);
$coauthors_plus->add_coauthors($blog2_post1, array($author2_obj->user_login), true);
/**
* Author 2 is now on the blog, and published
*/
$this->go_to(get_author_posts_url($author2));
$this->assertQueryTrue('is_author', 'is_archive');
// Remove the user from the blog
remove_user_from_blog($author2, $blog2);
/**
* Author 2 was removed from the blog, but still a published author
*/
$this->go_to(get_author_posts_url($author2));
$this->assertQueryTrue('is_author', 'is_archive');
// Delete the user from the network
wpmu_delete_user($author2);
/**
* Author 2 is no more
*/
$this->go_to(get_author_posts_url($author2));
$this->assertQueryTrue('is_404');
$this->assertEquals(false, get_user_by('id', $author2));
restore_current_blog();
}
开发者ID:voceconnect,项目名称:Co-Authors-Plus,代码行数:61,代码来源:test-author-queries.php
示例7: _destroy_user
function _destroy_user($user_id)
{
//non-admin
if (!function_exists('wp_delete_user')) {
require_once ABSPATH . 'wp-admin/includes/user.php';
}
if (is_multisite()) {
wpmu_delete_user($user_id);
} else {
wp_delete_user($user_id);
}
}
开发者ID:Beelegumes,项目名称:syst-ass-web,代码行数:12,代码来源:bootstrap.php
示例8: tearDownAfterClass
public static function tearDownAfterClass()
{
if (is_multisite()) {
wpmu_delete_user(self::$user_id);
} else {
wp_delete_user(self::$user_id);
}
foreach (self::$post_ids as $post_id) {
wp_delete_post($post_id, true);
}
self::commit_transaction();
}
开发者ID:Benrajalu,项目名称:philRaj,代码行数:12,代码来源:countUserPosts.php
示例9: test_wp_authenticate_spam_check_returns_wp_error_when_flagged
function test_wp_authenticate_spam_check_returns_wp_error_when_flagged()
{
if (!is_multisite()) {
$this->markTestSkipped('This test applies to multisite only.');
}
$user_id = self::factory()->user->create(array('role' => 'contributor'));
update_user_status($user_id, 'spam', 1);
$user = new WP_User($user_id);
$actual_user = wp_authenticate_spam_check($user);
wpmu_delete_user($user_id);
$this->assertInstanceOf('WP_Error', $actual_user);
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:12,代码来源:wpAuthenticateSpamCheck.php
示例10: tearDownAfterClass
public static function tearDownAfterClass()
{
foreach (array_merge(self::$users, array(self::$fred_id)) as $user_id) {
if (is_multisite()) {
wpmu_delete_user($user_id);
} else {
wp_delete_user($user_id);
}
}
foreach (self::$posts as $post_id) {
wp_delete_post($post_id, true);
}
self::commit_transaction();
}
开发者ID:Benrajalu,项目名称:philRaj,代码行数:14,代码来源:listAuthors.php
示例11: tearDownAfterClass
public static function tearDownAfterClass()
{
foreach (self::$groups as $group) {
groups_delete_group($group);
}
if (is_multisite()) {
wpmu_delete_user(self::$user);
wpmu_delete_user(self::$admin_user);
} else {
wp_delete_user(self::$user);
wp_delete_user(self::$admin_user);
}
self::commit_transaction();
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:14,代码来源:groupsIsUser.php
示例12: tearDownAfterClass
public static function tearDownAfterClass()
{
foreach (self::$group_ids as $group_id) {
groups_delete_group($group_id);
}
foreach (self::$user_ids as $user_id) {
if (is_multisite()) {
wpmu_delete_user($user_id);
} else {
wp_delete_user($user_id);
}
}
self::commit_transaction();
}
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:14,代码来源:suggestions-nonauth.php
示例13: tearDownAfterClass
public static function tearDownAfterClass()
{
if (is_multisite()) {
wpmu_delete_user(self::$editor_user);
wpmu_delete_user(self::$author_user);
} else {
wp_delete_user(self::$editor_user);
wp_delete_user(self::$author_user);
}
wp_delete_post(self::$editor_private_post, true);
wp_delete_post(self::$author_private_post, true);
wp_delete_post(self::$editor_privatefoo_post, true);
wp_delete_post(self::$author_privatefoo_post, true);
self::commit_transaction();
}
开发者ID:Benrajalu,项目名称:philRaj,代码行数:15,代码来源:postStatus.php
示例14: test_get_blogs_of_user
/**
* Test that usermeta cache is cleared after user deletion.
*
* @ticket 19500
*/
function test_get_blogs_of_user()
{
// Logged out users don't have blogs.
$this->assertEquals(array(), get_blogs_of_user(0));
$user_id = $this->factory->user->create(array('role' => 'subscriber'));
$blogs = get_blogs_of_user($user_id);
$this->assertEquals(array(1), array_keys($blogs));
// Non-existent users don't have blogs.
if (is_multisite()) {
wpmu_delete_user($user_id);
} else {
wp_delete_user($user_id);
}
$user = new WP_User($user_id);
$this->assertFalse($user->exists(), 'WP_User->exists');
$this->assertEquals(array(), get_blogs_of_user($user_id));
}
开发者ID:plis197715,项目名称:wordpress-develop,代码行数:22,代码来源:wpDeleteUser.php
示例15: tearDown
public function tearDown()
{
global $wpdb;
parent::tearDown();
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();
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:18,代码来源:testcase.php
示例16: import_users
/**
* Import users from csv file and remove any existing users that is not.
* @subcommand import-users
* @synopsis <csv-file>
*/
public function import_users($args, $assoc_args)
{
global $wpdb;
$file = $args[0];
if (!($fh = fopen($file, 'r'))) {
return;
}
$users = array();
if ($headers = fgetcsv($fh)) {
while ($row = fgetcsv($fh)) {
if (count($headers) != count($row)) {
continue;
}
$users[] = array_combine($headers, $row);
}
}
fclose($fh);
if (empty($users)) {
return;
}
$users = wp_list_pluck($users, 'user_login');
$blogs = $wpdb->get_results("SELECT * FROM {$wpdb->blogs}");
$existing_users = get_users(array('blog_id' => 1));
foreach ($existing_users as $user) {
// don't remove super admin
if ($user->ID == 1 || is_super_admin($user->ID)) {
continue;
}
if (!in_array($user->user_login, $users)) {
foreach ($blogs as $blog) {
remove_user_from_blog($user->ID, $blog->blog_id, 1);
printf("Remove user %s from %s\n", $user->user_login, $blog->domain);
}
printf("Delete user %s\n", $user->user_login);
wpmu_delete_user($user->ID);
}
}
switch_to_blog(1);
add_filter('send_password_change_email', '__return_false');
\WP_CLI\Utils\load_command('user');
$user = new User_Command();
$user->import_csv($args, $assoc_args);
$this->add_network_users();
}
开发者ID:amandhare,项目名称:vip-quickstart,代码行数:49,代码来源:pmc-wp-cli.php
示例17: delete
/**
* Delete one or more users from the current site.
*
* ## OPTIONS
*
* <user>...
* : The user login, user email, or user ID of the user(s) to delete.
*
* [--network]
* : On multisite, delete the user from the entire network.
*
* [--reassign=<user-id>]
* : User ID to reassign the posts to.
*
* [--yes]
* : Answer yes to any confirmation prompts.
*
* ## EXAMPLES
*
* # Delete user 123 and reassign posts to user 567
* $ wp user delete 123 --reassign=567
* Success: Removed user 123 from http://example.com
*/
public function delete($args, $assoc_args)
{
$network = \WP_CLI\Utils\get_flag_value($assoc_args, 'network') && is_multisite();
$reassign = \WP_CLI\Utils\get_flag_value($assoc_args, 'reassign');
if ($network && $reassign) {
WP_CLI::error('Reassigning content to a different user is not supported on multisite.');
}
if (!$reassign) {
WP_CLI::confirm('--reassign parameter not passed. All associated posts will be deleted. Proceed?', $assoc_args);
}
$users = $this->fetcher->get_many($args);
parent::_delete($users, $assoc_args, function ($user) use($network, $reassign) {
$user_id = $user->ID;
if ($network) {
$r = wpmu_delete_user($user_id);
$message = "Deleted user {$user_id}.";
} else {
$r = wp_delete_user($user_id, $reassign);
$message = "Removed user {$user_id} from " . home_url() . ".";
}
if ($r) {
return array('success', $message);
} else {
return array('error', "Failed deleting user {$user_id}.");
}
});
}
开发者ID:voldemortensen,项目名称:wp-cli,代码行数:50,代码来源:user.php
示例18: remove_user_from_blog
}
if (!empty($_POST['delete']) && 'reassign' == $_POST['delete'][$blogid][$id]) {
remove_user_from_blog($id, $blogid, $user_id);
} else {
remove_user_from_blog($id, $blogid);
}
}
}
}
$i = 0;
if (is_array($_POST['user']) && !empty($_POST['user'])) {
foreach ($_POST['user'] as $id) {
if (!current_user_can('delete_user', $id)) {
continue;
}
wpmu_delete_user($id);
$i++;
}
}
if ($i == 1) {
$deletefunction = 'delete';
} else {
$deletefunction = 'all_delete';
}
wp_redirect(add_query_arg(array('updated' => 'true', 'action' => $deletefunction), network_admin_url('users.php')));
exit;
break;
}
}
$wp_list_table = _get_list_table('WP_MS_Users_List_Table');
$pagenum = $wp_list_table->get_pagenum();
开发者ID:redteam,项目名称:wordpress-,代码行数:31,代码来源:users.php
示例19: test_is_user_member_of_blog
function test_is_user_member_of_blog() {
global $wpdb;
$user1_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
$old_current = get_current_user_id();
wp_set_current_user( $user1_id );
$this->assertTrue( is_user_member_of_blog() );
$this->assertTrue( is_user_member_of_blog( 0, 0 ) );
$this->assertTrue( is_user_member_of_blog( 0, $wpdb->blogid ) );
$this->assertTrue( is_user_member_of_blog( $user1_id ) );
$this->assertTrue( is_user_member_of_blog( $user1_id, $wpdb->blogid ) );
$blog_ids = $this->factory->blog->create_many( 5 );
foreach ( $blog_ids as $blog_id ) {
$this->assertInternalType( 'int', $blog_id );
$this->assertTrue( is_user_member_of_blog( $user1_id, $blog_id ) );
$this->assertTrue( remove_user_from_blog( $user1_id, $blog_id ) );
$this->assertFalse( is_user_member_of_blog( $user1_id, $blog_id ) );
}
wpmu_delete_user( $user1_id );
$user = new WP_User( $user1_id );
$this->assertFalse( $user->exists(), 'WP_User->exists' );
$this->assertFalse( is_user_member_of_blog( $user1_id ), 'is_user_member_of_blog' );
wp_set_current_user( $old_current );
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:29,代码来源:ms.php
示例20: test_update_existing_network_user_on_sub_site_adds_user_to_site
public function test_update_existing_network_user_on_sub_site_adds_user_to_site()
{
if (!is_multisite()) {
$this->markTestSkipped('Test requires multisite.');
}
$this->allow_user_to_manage_multisite();
$params = array('username' => 'testuser123', 'password' => 'testpassword', 'email' => '[email protected]', 'name' => 'Test User 123', 'roles' => array('editor'));
$request = new WP_REST_Request('POST', '/wp/v2/users');
$request->add_header('content-type', 'application/x-www-form-urlencoded');
$request->set_body_params($params);
$response = $this->server->dispatch($request);
$data = $response->get_data();
$user_id = $data['id'];
switch_to_blog(self::$site);
$request = new WP_REST_Request('PUT', '/wp/v2/users/' . $user_id);
$request->add_header('content-type', 'application/x-www-form-urlencoded');
$request->set_body_params($params);
$this->server->dispatch($request);
restore_current_blog();
$user_is_member = is_user_member_of_blog($user_id, self::$site);
wpmu_delete_user($user_id);
$this->assertTrue($user_is_member);
}
开发者ID:kucrut,项目名称:wordpress,代码行数:23,代码来源:rest-users-controller.php
注:本文中的wpmu_delete_user函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论