当前位置: 首页>>代码示例>>PHP>>正文


PHP remove_user_from_blog函数代码示例

本文整理汇总了PHP中remove_user_from_blog函数的典型用法代码示例。如果您正苦于以下问题:PHP remove_user_from_blog函数的具体用法?PHP remove_user_from_blog怎么用?PHP remove_user_from_blog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了remove_user_from_blog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: include_professors

function include_professors()
{
    $admin_id = get_user_id_from_string(get_blog_option($current_blog->blog_id, 'admin_email'));
    $blog_major = get_user_major();
    //get_the_user_major($admin_id);
    //var_dump($blog_major);
    if ($GLOBALS['blog_id'] != 1) {
        //makes sure it's not the root blog
        $args = array('blog_id' => 1, 'role' => 'professor');
        $professors = get_users($args);
        //get all profs from root blog
        //loop through profs, add as user if same major, delete if different major
        foreach ($professors as $professor) {
            $prof_major = get_the_user_major($professor->ID);
            //var_dump($prof_major);
            if ($prof_major == $blog_major) {
                $current_role = get_the_user_role($professor);
                if ($current_role != 'Administrator') {
                    $result = add_existing_user_to_blog(array('user_id' => $professor->ID, 'role' => 'professor'));
                }
            } else {
                $result = remove_user_from_blog($professor->ID, $current_blog->blog_id);
            }
        }
    }
    //end if
}
开发者ID:ryanshoover,项目名称:seufolios,代码行数:27,代码来源:role_setup.php

示例2: test_get_active_blog_for_user_with_no_sites

 /**
  * @ticket 38355
  */
 public function test_get_active_blog_for_user_with_no_sites()
 {
     $current_site_id = get_current_blog_id();
     remove_user_from_blog(self::$user_id, $current_site_id);
     $result = get_active_blog_for_user(self::$user_id);
     $this->assertNull($result);
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:10,代码来源:getActiveBlogForUser.php

示例3: remove_user

 /**
  * Removes a user from the current site.
  * @param  int $user_id
  * @return array|WP_Error
  */
 function remove_user($user_id)
 {
     if (!current_user_can('remove_users')) {
         return new WP_Error('unauthorized', 'User cannot remove users for specified site.', 403);
     }
     if (!is_user_member_of_blog($user_id, get_current_blog_id())) {
         return new WP_Error('invalid_input', 'User is not a member of the specified site.', 400);
     }
     return array('success' => remove_user_from_blog($user_id, get_current_blog_id()));
 }
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:15,代码来源:class.wpcom-json-api-update-user-endpoint.php

示例4: 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

示例5: test_get_dashboard_url_for_administrator_of_different_site

 /**
  * @ticket 39065
  */
 public function test_get_dashboard_url_for_administrator_of_different_site()
 {
     if (!is_multisite()) {
         $this->markTestSkipped('Test only runs in multisite.');
     }
     $site_id = self::factory()->blog->create(array('user_id' => self::$user_id));
     remove_user_from_blog(self::$user_id, get_current_blog_id());
     $expected = get_admin_url($site_id);
     $result = get_dashboard_url(self::$user_id);
     remove_user_from_blog(self::$user_id, $site_id);
     add_user_to_blog(get_current_blog_id(), self::$user_id, 'administrator');
     wpmu_delete_blog($site_id, true);
     $this->assertEquals($expected, $result);
 }
开发者ID:CompositeUK,项目名称:clone.WordPress-Develop,代码行数:17,代码来源:getDashboardUrl.php

示例6: thatcamp_clear_boone

/**
 * Mods the admin bar
 */
function thatcamp_clear_boone()
{
    if (is_super_admin() && !empty($_GET['clear_boone'])) {
        global $wpdb;
        $blogs = $wpdb->get_results("SELECT blog_id, domain FROM {$wpdb->blogs}");
        $boone = $wpdb->get_var("SELECT ID FROM {$wpdb->users} WHERE user_login = 'boone'");
        $boone_camps = array(2, 3, 21, 57, 77, 122);
        foreach ($blogs as $blog) {
            if (!in_array($blog->blog_id, $boone_camps)) {
                remove_user_from_blog($boone, $blog->blog_id);
                echo $blog->domain . '<br />';
            }
        }
    }
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:18,代码来源:thatcamp-adminbar.php

示例7: thatcamp_remove_users_from_blog_i

function thatcamp_remove_users_from_blog_i()
{
    $blog_id = 168;
    $users_to_keep = array(852);
    $users = get_users(array('blog_id' => $blog_id, 'number' => 5, 'fields' => ''));
    foreach ($users as $user) {
        if (in_array($user, $users_to_keep)) {
            //                        echo 'Keeping ' . $user;
        } else {
            //                        echo 'Dumping ' . $user;
            remove_user_from_blog($user, $blog_id);
            //                                $user_object = new WP_User( $user );
            //                               $user_object->set_role( '' );
        }
        echo '<br />';
    }
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:17,代码来源:thatcamp-toolbox.php

示例8: widget_suscribe

 function widget_suscribe()
 {
     global $wpdb, $current_user;
     $options = get_option('widget_suscribe');
     $before_widget = "<li id='subscribe'>";
     $before_title = "<h2>";
     $title = empty($options['title']) ? 'Suscr&iacute;bete a este blog' : $options['title'];
     $after_title = "</h2>";
     $content = "";
     $after_widget = "</li>";
     //error_log("[widget subscribe] current blog: ". $wpdb->blogid);
     //error_log("[widget subscribe] current user: ". $current_user->ID);
     // User is already in blog database
     if (is_blog_user($wpdb->blogid)) {
         //error_log("[widget subscribe] is blog user");
         // User wants to unsubscribe
         if (isset($_POST['unsuscribe'])) {
             //error_log("[widget subscribe] POST[unsuscribe]");
             remove_user_from_blog($current_user->ID, $wpdb->blogid);
             $content .= '<p>Te has desuscrito de este blog</p>';
             $content .= widget_subscribe_form();
         } elseif ($current_user->has_cap('subscriber')) {
             //error_log("[widget subscribe] has_cap('subscriber')");
             $content .= widget_unsubscribe_form();
         } elseif ($current_user->has_cap('edit_posts')) {
             $content .= "<p>Este blog tiene activado el widget de suscripci&oacute;n</p>";
         }
     } else {
         //error_log("[widget subscribe] not in log");
         // User wants to subscribe
         if (isset($_POST['suscribe'])) {
             //error_log("[widget subscribe] POST[suscribe]");
             add_user_to_blog($wpdb->blogid, $current_user->ID, 'subscriber');
             $content .= '<p>Te has suscrito a este blog</p>';
             $content .= widget_unsubscribe_form();
         } else {
             //error_log("[widget subscribe] subscribe form");
             $content .= widget_subscribe_form();
         }
     }
     echo $before_widget . $before_title . $title . $after_title . $content . $after_widget;
 }
开发者ID:alx,项目名称:blogsfera,代码行数:42,代码来源:widget-suscribe.php

示例9: add_network_users

 /**
  * @subcommand add-network-users
  */
 public function add_network_users()
 {
     global $wpdb;
     $users = get_users(array('blog_id' => 1));
     $blogs = $wpdb->get_results("SELECT * FROM {$wpdb->blogs} where blog_id <> 1");
     foreach ($users as $user) {
         if (empty($user)) {
             continue;
         }
         foreach ($blogs as $blog) {
             if (empty($blog)) {
                 continue;
             }
             foreach ($user->roles as $role) {
                 remove_user_from_blog($user->ID, $blog->blog_id, 1);
                 add_user_to_blog($blog->blog_id, $user->ID, $role);
             }
             printf("add user %s to %s\n", $user->user_login, $blog->domain);
         }
     }
 }
开发者ID:amandhare,项目名称:vip-quickstart,代码行数:24,代码来源:pmc-wp-cli.php

示例10: wp_delete_user

/**
 * Remove user and optionally reassign posts and links to another user.
 *
 * If the $reassign parameter is not assigned to an 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.
 *
 * @since 2.0.0
 *
 * @param int $id User ID.
 * @param int $reassign Optional. Reassign posts and links to new User ID.
 * @return bool True when finished.
 */
function wp_delete_user($id, $reassign = 'novalue')
{
    global $wpdb;
    $id = (int) $id;
    $user = new WP_User($id);
    // allow for transaction statement
    do_action('delete_user', $id);
    if ('novalue' === $reassign || null === $reassign) {
        $post_types_to_delete = array();
        foreach (get_post_types(array(), 'objects') as $post_type) {
            if ($post_type->delete_with_user) {
                $post_types_to_delete[] = $post_type->name;
            } elseif (null === $post_type->delete_with_user && post_type_supports($post_type->name, 'author')) {
                $post_types_to_delete[] = $post_type->name;
            }
        }
        $post_types_to_delete = apply_filters('post_types_to_delete_with_user', $post_types_to_delete, $id);
        $post_types_to_delete = implode("', '", $post_types_to_delete);
        $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_type IN ('{$post_types_to_delete}')", $id));
        if ($post_ids) {
            foreach ($post_ids as $post_id) {
                wp_delete_post($post_id);
            }
        }
        // Clean links
        $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
        if ($link_ids) {
            foreach ($link_ids as $link_id) {
                wp_delete_link($link_id);
            }
        }
    } else {
        $reassign = (int) $reassign;
        $wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
        $wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
    }
    // FINALLY, delete user
    if (is_multisite()) {
        remove_user_from_blog($id, get_current_blog_id());
    } else {
        $meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
        foreach ($meta as $mid) {
            delete_metadata_by_mid('user', $mid);
        }
        $wpdb->delete($wpdb->users, array('ID' => $id));
    }
    clean_user_cache($user);
    // allow for commit transaction
    do_action('deleted_user', $id);
    return true;
}
开发者ID:dcatontopcorp,项目名称:wordpress,代码行数:65,代码来源:user.php

示例11: wpmu_delete_user

function wpmu_delete_user( $id ) {
	global $wpdb;

	$id = (int) $id;

	do_action( 'wpmu_delete_user', $id );

	$blogs = get_blogs_of_user( $id );

	if ( ! empty( $blogs ) ) {
		foreach ( $blogs as $blog ) {
			switch_to_blog( $blog->userblog_id );
			remove_user_from_blog( $id, $blog->userblog_id );

			$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
			foreach ( (array) $post_ids as $post_id ) {
				wp_delete_post( $post_id );
			}

			// Clean links
			$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );

			if ( $link_ids ) {
				foreach ( $link_ids as $link_id )
					wp_delete_link( $link_id );
			}

			restore_current_blog();
		}
	}

	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->users WHERE ID = %d", $id ) );
	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id ) );

	clean_user_cache( $id );

	// allow for commit transaction
	do_action( 'deleted_user', $id );

	return true;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:41,代码来源:ms.php

示例12: check_admin_referer

     break;
 case 'dodelete':
     check_admin_referer('ms-users-delete');
     if (!(current_user_can('manage_network_users') && current_user_can('delete_users'))) {
         wp_die(__('You do not have permission to access this page.'));
     }
     if (!empty($_POST['blog']) && is_array($_POST['blog'])) {
         foreach ($_POST['blog'] as $id => $users) {
             foreach ($users as $blogid => $user_id) {
                 if (!current_user_can('delete_user', $id)) {
                     continue;
                 }
                 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) {
开发者ID:redteam,项目名称:wordpress-,代码行数:31,代码来源:users.php

示例13: add_new_user_to_blog

/**
 * Add a newly created user to the appropriate blog
 *
 * To add a user in general, use add_user_to_blog(). This function
 * is specifically hooked into the wpmu_activate_user action.
 *
 * @since MU
 * @see add_user_to_blog()
 *
 * @param int   $user_id
 * @param mixed $password Ignored.
 * @param array $meta
 */
function add_new_user_to_blog($user_id, $password, $meta)
{
    if (!empty($meta['add_to_blog'])) {
        $blog_id = $meta['add_to_blog'];
        $role = $meta['new_role'];
        remove_user_from_blog($user_id, get_current_site()->blog_id);
        // remove user from main blog.
        add_user_to_blog($blog_id, $user_id, $role);
        update_user_meta($user_id, 'primary_blog', $blog_id);
    }
}
开发者ID:Jitsufreak,项目名称:PJ,代码行数:24,代码来源:ms-functions.php

示例14: die

     }
     break;
 case 'remove':
     if (!current_user_can('remove_users')) {
         die(__('You can&#8217;t remove users.'));
     }
     check_admin_referer('bulk-users');
     $update = 'remove';
     if (isset($_REQUEST['users'])) {
         $userids = $_REQUEST['users'];
         foreach ($userids as $user_id) {
             $user_id = (int) $user_id;
             remove_user_from_blog($user_id, $id);
         }
     } elseif (isset($_GET['user'])) {
         remove_user_from_blog($_GET['user']);
     } else {
         $update = 'err_remove';
     }
     break;
 case 'promote':
     check_admin_referer('bulk-users');
     $editable_roles = get_editable_roles();
     if (empty($editable_roles[$_REQUEST['new_role']])) {
         wp_die(__('You can&#8217;t give users that role.'));
     }
     if (isset($_REQUEST['users'])) {
         $userids = $_REQUEST['users'];
         $update = 'promote';
         foreach ($userids as $user_id) {
             $user_id = (int) $user_id;
开发者ID:mostafiz93,项目名称:PrintfScanf,代码行数:31,代码来源:site-users.php

示例15: wp_delete_user

/**
 * 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.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int $id User ID.
 * @param int $reassign Optional. Reassign posts and links to new User ID.
 * @return bool True when finished.
 */
function wp_delete_user($id, $reassign = null)
{
    global $wpdb;
    if (!is_numeric($id)) {
        return false;
    }
    $id = (int) $id;
    $user = new WP_User($id);
    if (!$user->exists()) {
        return false;
    }
    // Normalize $reassign to null or a user ID. 'novalue' was an older default.
    if ('novalue' === $reassign) {
        $reassign = null;
    } elseif (null !== $reassign) {
        $reassign = (int) $reassign;
    }
    /**
     * Fires immediately before a user is deleted from the database.
     *
     * @since 2.0.0
     *
     * @param int      $id       ID of the user to delete.
     * @param int|null $reassign ID of the user to reassign posts and links to.
     *                           Default null, for no reassignment.
     */
    do_action('delete_user', $id, $reassign);
    if (null === $reassign) {
        $post_types_to_delete = array();
        foreach (get_post_types(array(), 'objects') as $post_type) {
            if ($post_type->delete_with_user) {
                $post_types_to_delete[] = $post_type->name;
            } elseif (null === $post_type->delete_with_user && post_type_supports($post_type->name, 'author')) {
                $post_types_to_delete[] = $post_type->name;
            }
        }
        /**
         * Filter the list of post types to delete with a user.
         *
         * @since 3.4.0
         *
         * @param array $post_types_to_delete Post types to delete.
         * @param int   $id                   User ID.
         */
        $post_types_to_delete = apply_filters('post_types_to_delete_with_user', $post_types_to_delete, $id);
        $post_types_to_delete = implode("', '", $post_types_to_delete);
        $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_type IN ('{$post_types_to_delete}')", $id));
        if ($post_ids) {
            foreach ($post_ids as $post_id) {
                wp_delete_post($post_id);
            }
        }
        // Clean links
        $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
        if ($link_ids) {
            foreach ($link_ids as $link_id) {
                wp_delete_link($link_id);
            }
        }
    } else {
        $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
        $wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
        if (!empty($post_ids)) {
            foreach ($post_ids as $post_id) {
                clean_post_cache($post_id);
            }
        }
        $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
        $wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
        if (!empty($link_ids)) {
            foreach ($link_ids as $link_id) {
                clean_bookmark_cache($link_id);
            }
        }
    }
    // FINALLY, delete user
    if (is_multisite()) {
        remove_user_from_blog($id, get_current_blog_id());
    } else {
        $meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
        foreach ($meta as $mid) {
            delete_metadata_by_mid('user', $mid);
        }
        $wpdb->delete($wpdb->users, array('ID' => $id));
//.........这里部分代码省略.........
开发者ID:huchka,项目名称:WordPress,代码行数:101,代码来源:user.php


注:本文中的remove_user_from_blog函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。