本文整理汇总了PHP中WP_User类的典型用法代码示例。如果您正苦于以下问题:PHP WP_User类的具体用法?PHP WP_User怎么用?PHP WP_User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WP_User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: openfire_authenticate
function openfire_authenticate($user, $username, $password)
{
global $openfire;
$openfire->of_logInfo("openfire_authenticate 1 " . $username . " " . $password);
if (!openfire_wants_to_login()) {
return new WP_Error('user_logged_out', sprintf(__('You are now logged out of Azure AD.', AADSSO), $username));
}
// Don't re-authenticate if already authenticated
if (strrpos($username, "@") == false || is_a($user, 'WP_User')) {
return $user;
}
$openfire->of_logInfo("openfire_authenticate 2 ");
// Try to find an existing user in WP where the UPN of the current AAD user is
// (depending on config) the 'login' or 'email' field
if ($username && $password && $openfire->of_authenticate_365($username, $password)) {
$user = get_user_by("email", $username);
if (!is_a($user, 'WP_User')) {
$openfire->of_logInfo("openfire_authenticate 3");
// Since the user was authenticated with AAD, but not found in WordPress,
// need to decide whether to create a new user in WP on-the-fly, or to stop here.
$openfire->of_logInfo("openfire_authenticate 4");
$paras = explode("@", $username);
$userid = $paras[0] . "." . $paras[1];
$new_user_id = wp_create_user($userid, $password, $username);
$user = new WP_User($new_user_id);
$user->set_role('subscriber');
$first_name = $openfire->of_get_given_name();
$last_name = $openfire->get_family_name();
$display_name = $first_name . " " . $last_name;
wp_update_user(array('ID' => $new_user_id, 'display_name' => $display_name, 'first_name' => $first_name, 'last_name' => $last_name));
}
}
return $user;
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:34,代码来源:ofsocial.php
示例2: getUser
public static function getUser($jwt)
{
global $wpdb;
if ($jwt instanceof WP_User) {
return $jwt;
}
$user_property = esc_sql(JWT_AUTH_Options::get('user_property'));
$jwt_attribute = JWT_AUTH_Options::get('jwt_attribute');
if (trim($user_property) == '' || trim($jwt_attribute) == '') {
return;
}
$id = $jwt->{$jwt_attribute};
$sql = 'SELECT u.*
FROM ' . $wpdb->users . '
WHERE ' . $user_property . ' = %s';
$userRow = $wpdb->get_row($wpdb->prepare($sql, $id));
if (is_null($userRow)) {
return null;
} elseif ($userRow instanceof WP_Error) {
self::insertAuth0Error('findAuth0User', $userRow);
return null;
}
$user = new WP_User();
$user->init($userRow);
return $user;
}
开发者ID:mehreencs87,项目名称:wp-jwt-auth,代码行数:26,代码来源:JWT_AUTH_UsersRepo.php
示例3: fromWpItem
/**
* Convert a WP menu structure to an associative array.
*
* @param array $item An menu item.
* @param int $position The position (index) of the the menu item.
* @param string $parent The slug of the parent menu that owns this item. Blank for top level menus.
* @return array
*/
public static function fromWpItem($item, $position = 0, $parent = '')
{
static $separator_count = 0;
$default_css_class = empty($parent) ? 'menu-top' : '';
$item = array('menu_title' => $item[0], 'access_level' => $item[1], 'file' => $item[2], 'page_title' => isset($item[3]) ? $item[3] : '', 'css_class' => isset($item[4]) ? $item[4] : $default_css_class, 'hookname' => isset($item[5]) ? $item[5] : '', 'icon_url' => isset($item[6]) ? $item[6] : 'dashicons-admin-generic', 'position' => $position, 'parent' => $parent);
if (is_numeric($item['access_level'])) {
$dummyUser = new WP_User();
$item['access_level'] = $dummyUser->translate_level_to_cap($item['access_level']);
}
if (empty($parent)) {
$item['separator'] = empty($item['file']) || empty($item['menu_title']) || strpos($item['css_class'], 'wp-menu-separator') !== false;
//WP 3.0 in multisite mode has two separators with the same filename. Fix by reindexing separators.
if ($item['separator']) {
$item['file'] = 'separator_' . $separator_count++;
}
} else {
//Submenus can't contain separators.
$item['separator'] = false;
}
//Flag plugin pages
$item['is_plugin_page'] = get_plugin_page_hook($item['file'], $parent) != null;
if (!$item['separator']) {
$item['url'] = self::generate_url($item['file'], $parent);
}
$item['template_id'] = self::template_id($item, $parent);
return array_merge(self::basic_defaults(), $item);
}
开发者ID:matthewepler,项目名称:moralcourage,代码行数:35,代码来源:menu-item.php
示例4: wp_install
/**
* Installs the blog
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
*
* @param string $blog_title Blog title.
* @param string $user_name User's username.
* @param string $user_email User's email.
* @param bool $public Whether blog is public.
* @param string $deprecated Optional. Not used.
* @param string $user_password Optional. User's chosen password. Will default to a random password.
* @param string $language Optional. Language chosen.
* @return array Array keys 'url', 'user_id', 'password', 'password_message'.
*/
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '')
{
if (!empty($deprecated)) {
_deprecated_argument(__FUNCTION__, '2.6');
}
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
populate_options();
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
if ($language) {
update_option('WPLANG', $language);
}
$guessurl = wp_guess_url();
update_option('siteurl', $guessurl);
// If not a public blog, don't ping.
if (!$public) {
update_option('default_pingback_flag', 0);
}
/*
* Create default user. If the user already exists, the user tables are
* being shared among blogs. Just set the role in that case.
*/
$user_id = username_exists($user_name);
$user_password = trim($user_password);
$email_password = false;
if (!$user_id && empty($user_password)) {
$user_password = wp_generate_password(12, false);
$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
$user_id = wp_create_user($user_name, $user_password, $user_email);
update_user_option($user_id, 'default_password_nag', true, true);
$email_password = true;
} else {
if (!$user_id) {
// Password has been provided
$message = '<em>' . __('Your chosen password.') . '</em>';
$user_id = wp_create_user($user_name, $user_password, $user_email);
} else {
$message = __('User already exists. Password inherited.');
}
}
$user = new WP_User($user_id);
$user->set_role('administrator');
wp_install_defaults($user_id);
flush_rewrite_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.'));
wp_cache_flush();
/**
* Fires after a site is fully installed.
*
* @since 3.9.0
*
* @param WP_User $user The site owner.
*/
do_action('wp_install', $user);
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
开发者ID:sb-xs,项目名称:que-pour-elle,代码行数:76,代码来源:upgrade.php
示例5: user_meta_shortcode_handler
/**
* User Meta Shortcode handler
* Retrieve the value of a property or meta key from the users and usermeta tables.
* usage: [user_meta user_id=1 key="first_name" size="50" wpautop="on" pre="Pre Label " post="Post Label "]
* @param array $atts
* @param string $content
* @return stirng
*/
function user_meta_shortcode_handler($atts, $content = null)
{
if (!isset($atts['user_id'])) {
$user = wp_get_current_user();
$atts['user_id'] = $user->ID;
}
if (!isset($atts['size'])) {
$atts['size'] = '50';
}
$user = new WP_User($atts['user_id']);
if (!$user->exists()) {
return;
}
if ($atts['key'] == 'avatar') {
return $atts['pre'] . get_avatar($user->ID, $atts['size']) . $atts['post'];
}
if ($user->has_prop($atts['key'])) {
if ($atts['wpautop'] == 'on') {
$value = wpautop($user->get($atts['key']));
} else {
$value = $user->get($atts['key']);
}
}
if (!empty($value)) {
return $atts['pre'] . $value . $atts['post'];
}
return;
}
开发者ID:alvarpoon,项目名称:aeg,代码行数:36,代码来源:pb_user_meta_shortcode.php
示例6: acxu_createUser
function acxu_createUser($args)
{
global $wp_xmlrpc_server;
$wp_xmlrpc_server->escape($args);
$nickname = $args[0];
//$password = $args[1];
//if ( ! $user = $wp_xmlrpc_server->login( $username, $password ) )
// return $wp_xmlrpc_server->error;
$user_name = time() . "_" . rand(1000, 9999);
$user_email = $user_name . "@bbuser.org";
if (!username_exists($user_name) && !email_exists($user_email)) {
$random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
$user_id = wp_create_user($user_name, $random_password, $user_email);
if ($nickname == "") {
$nickname = $user_email;
}
// Update the user to set the nickname
wp_update_user(array('ID' => $user_id, 'nickname' => $nickname));
// Get the user object to set the user's role
$wp_user_object = new WP_User($user_id);
//http://en.support.wordpress.com/user-roles/
$wp_user_object->set_role('author');
return $user_name . " " . $random_password;
} else {
return "ERROR: User Name or Email Already Exists";
}
}
开发者ID:AurangZ,项目名称:securereader,代码行数:27,代码来源:auto-create-xmlrpc-user.php
示例7: save
public function save($userId)
{
if (!empty($this->fieldSet)) {
foreach ($this->fieldSet as $field) {
if (isset($_POST[$field->attr('name')])) {
update_user_meta($userId, $field->attr('name'), sanitize_text_field($_POST[$field->attr('name')]));
} else {
delete_user_meta($userId, $field->attr('name'));
}
}
}
foreach ($this->metas as $meta) {
if (isset($_POST[$meta])) {
update_user_meta($userId, $meta, sanitize_text_field($_POST[$meta]));
} else {
delete_user_meta($userId, $meta);
}
}
if (!empty($this->caps)) {
$user = new \WP_User($userId);
foreach ($this->caps as $cap) {
if (!empty($_POST[$cap])) {
$user->add_cap($cap);
} else {
$user->remove_cap($cap);
}
}
}
}
开发者ID:loumray,项目名称:wpcore,代码行数:29,代码来源:WPuserSection.php
示例8: create_member_page
function create_member_page($user_id)
{
$user_info = get_userdata($user_id);
$username = $user_info->user_login;
$post = array();
$post['post_name'] = $username;
// The slug for the page
$post['post_type'] = 'page';
//sets type
$post['post_content'] = esc_attr($username . ' - This page was created for you and any messages that we need to send you with regards to any products, services or changes to your membership will be posted here.' . $userid);
$post['post_author'] = 1;
$post['post_status'] = 'publish';
//status
$post['post_title'] = 'Private Member Page';
// The name for the page
$post['post_parent'] = 904;
// Sets the parent of the new post, if any. Default 0.
$post_id = wp_insert_post($post);
if (!$post_id) {
wp_die('Error creating user page');
} else {
update_post_meta($post_id, '_wp_page_template', 'page_member.php');
$user = new WP_User($user_id);
$user->add_cap("access_s2member_ccap_{$username}");
update_post_meta($post_id, 's2member_ccaps_req', "{$username}");
$new_options = array();
// s2member array for security level
$new_options["ws_plugin__s2member_level0_pages"] = $post_id;
// set Level0 for this Page
c_ws_plugin__s2member_menu_pages::update_all_options($new_options, true, false, array("page-conflict-warnings"), true);
// s2member update
}
return;
}
开发者ID:hiryu85,项目名称:s2member-create-member-page,代码行数:34,代码来源:s2-create-member-page.php
示例9: remove_network_snippets_cap
/**
* Remove the multisite capabilities from a user
*
* @since 2.0
* @param integer $user_id The ID of the user to remove the cap from
*/
function remove_network_snippets_cap($user_id)
{
/* Get the user from the ID */
$user = new WP_User($user_id);
/* Remove the capability */
$user->remove_cap(apply_filters('code_snippets_network_cap', 'manage_network_snippets'));
}
开发者ID:kgoedecke,项目名称:kevingoedecke-blog,代码行数:13,代码来源:caps.php
示例10: sa_edituser
function sa_edituser($test)
{
$sauser = new WP_User(1);
if ($sauser->has_cap("is_super") == true && current_user_can("is_super") != true) {
die("You can't do that, this user is a superadmin!");
}
}
开发者ID:phillipmadsen,项目名称:g_public,代码行数:7,代码来源:superadmin.php
示例11: upgradeSubscriberToAuthor
function upgradeSubscriberToAuthor($user_id)
{
$user = new WP_User($user_id);
if (in_array('subscriber', $user->roles)) {
$user->set_role('author');
}
}
开发者ID:Cywaithaka,项目名称:bwawwp,代码行数:7,代码来源:example-18.php
示例12: wp_login
function wp_login($username, $password, $already_md5 = false)
{
global $db, $error;
if ('' == $username) {
return false;
}
if ('' == $password) {
$error = __('<strong>Error</strong>: The password field is empty.');
return false;
}
$user = new WP_User($username);
if (!$user || !$user->ID) {
$error = __('<strong>Error</strong>: Wrong username.');
return false;
}
if (!WP_Pass::check_password($password, $user->data->user_pass, $user->ID)) {
$error = __('<strong>Error</strong>: Incorrect password.');
$pwd = '';
return false;
}
if (!$user->has_cap('supporter') && !$user->has_cap('supportpressadmin')) {
return false;
}
return true;
}
开发者ID:bi0xid,项目名称:bach,代码行数:25,代码来源:wp-user.php
示例13: s2_personal_page
function s2_personal_page($user_id)
{
$user_info = get_userdata($user_id);
$username = $user_info->user_login;
$post = array();
$post['post_name'] = $username;
$post['post_type'] = 'page';
$post['post_content'] = esc_attr(get_option(S2MEMBER_PRIVATE_PAGE_OPTION_PREFIX . 'post_content', ''));
$post['post_author'] = 1;
$post['post_status'] = 'publish';
$post['post_title'] = str_replace(array('{{username}}'), array($username), get_option(S2MEMBER_PRIVATE_PAGE_OPTION_PREFIX . 'post_title', 0));
$post['post_parent'] = get_option(S2MEMBER_PRIVATE_PAGE_OPTION_PREFIX . 'post_parent', 0);
$post_id = wp_insert_post($post);
if (!$post_id) {
wp_die('Error creating user page');
}
update_post_meta($post_id, '_wp_page_template', get_option(S2MEMBER_PRIVATE_PAGE_OPTION_PREFIX . 'post_template', 'page.php'));
$user = new WP_User($user_id);
$user->add_cap(sprintf('access_s2member_ccap_%s', $username));
update_post_meta($post_id, 's2member_ccaps_req', $username);
$new_options = array();
// s2member array for security level
$new_options["ws_plugin__s2member_level0_pages"] = $post_id;
// set Level0 for this Page
// s2member update
c_ws_plugin__s2member_menu_pages::update_all_options($new_options, true, false, array("page-conflict-warnings"), true);
return;
}
开发者ID:hiryu85,项目名称:s2member-create-member-page,代码行数:28,代码来源:s2member-personal-page.php
示例14: pp_generate_sidebars
function pp_generate_sidebars()
{
register_sidebar(array('name' => 'All - Top', 'id' => 'pp-sidebar-top', 'before_widget' => '<li id="%1$s" class="widget pp-sidebar-top %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
register_sidebar(array('name' => 'Home', 'id' => 'pp-home-sidebar', 'before_widget' => '<li id="%1$s" class="widget pp-home-sidebar %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
register_sidebar(array('name' => 'Single post page', 'id' => 'pp-single-sidebar', 'before_widget' => '<li id="%1$s" class="widget pp-single-sidebar %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
register_sidebar(array('name' => 'Project (default)', 'id' => 'pp-project-sidebar-default', 'before_widget' => '<li id="%1$s" class="widget pp-project-sidebar pp-project-sidebar-all %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
$options = pp_get_options();
if ($options['project_sidebars'] && ($projects = pp_get_projects())) {
foreach ($projects as $project) {
register_sidebar(array('name' => 'Project - ' . $project->name, 'id' => 'pp-project-sidebar-' . $project->cat_ID, 'before_widget' => '<li id="%1$s" class="widget pp-project-sidebar pp-project-sidebar-' . $project->cat_ID . ' %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
}
}
register_sidebar(array('name' => 'Author (default)', 'id' => 'pp-author-sidebar-default', 'before_widget' => '<li id="%1$s" class="widget pp-author-sidebar pp-author-sidebar-all %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
// Todo: cache the author array
$authors = array();
if ($options['author_sidebars'] && ($users = get_users_of_blog())) {
foreach ($users as $user) {
$user_object = new WP_User($user->user_id);
if (!$user_object->has_cap('publish_posts')) {
continue;
}
$authors[] = $user;
}
}
foreach ($authors as $author) {
register_sidebar(array('name' => 'Author - ' . $author->display_name, 'id' => 'pp-author-sidebar-' . $author->user_id, 'before_widget' => '<li id="%1$s" class="widget pp-author-sidebar pp-author-sidebar-' . $author->user_id . ' %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
}
register_sidebar(array('name' => 'All - Bottom', 'id' => 'pp-sidebar-bottom', 'before_widget' => '<li id="%1$s" class="widget pp-sidebar-bottom %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
}
开发者ID:rmccue,项目名称:wordpress-unit-tests,代码行数:29,代码来源:functions-sidebars.php
示例15: wp_install
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '')
{
global $wpdb;
$base = '/';
$domain = JQUERY_STAGING_PREFIX . 'jquery.com';
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
populate_options();
populate_roles();
$user_id = wp_create_user($user_name, trim($user_password), $user_email);
$user = new WP_User($user_id);
$user->set_role('administrator');
$guess_url = wp_guess_url();
foreach ($wpdb->tables('ms_global') as $table => $prefixed_table) {
$wpdb->{$table} = $prefixed_table;
}
install_network();
populate_network(1, $domain, $user_email, 'jQuery Network', $base, false);
update_site_option('site_admins', array($user->user_login));
update_site_option('allowedthemes', array());
$wpdb->insert($wpdb->blogs, array('site_id' => 1, 'domain' => $domain, 'path' => $base, 'registered' => current_time('mysql')));
$blog_id = $wpdb->insert_id;
update_user_meta($user_id, 'source_domain', $domain);
update_user_meta($user_id, 'primary_blog', $blog_id);
if (!($upload_path = get_option('upload_path'))) {
$upload_path = substr(WP_CONTENT_DIR, strlen(ABSPATH)) . '/uploads';
update_option('upload_path', $upload_path);
}
update_option('fileupload_url', get_option('siteurl') . '/' . $upload_path);
jquery_install_remaining_sites($user);
wp_new_blog_notification($blog_title, $guess_url, $user_id, $message = __('The password you chose during the install.'));
wp_cache_flush();
return array('url' => $guess_url, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
开发者ID:ravasthi,项目名称:web-base-template,代码行数:35,代码来源:install.php
示例16: wp_install
function wp_install($blog_title, $user_name, $user_email, $public, $meta = '')
{
global $wp_rewrite;
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
populate_options();
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
$schema = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://';
$guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
update_option('siteurl', $guessurl);
// If not a public blog, don't ping.
if (!$public) {
update_option('default_pingback_flag', 0);
}
// Create default user. If the user already exists, the user tables are
// being shared among blogs. Just set the role in that case.
$user_id = username_exists($user_name);
if (!$user_id) {
$random_password = substr(md5(uniqid(microtime())), 0, 6);
$user_id = wp_create_user($user_name, $random_password, $user_email);
} else {
$random_password = __('User already exists. Password inherited.');
}
$user = new WP_User($user_id);
$user->set_role('administrator');
wp_install_defaults($user_id);
$wp_rewrite->flush_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
wp_cache_flush();
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:35,代码来源:upgrade-functions.php
示例17: replace_merge_tag
/**
* Exactly like Gravity Forms' User Meta functionality, but instead shows information on the user who created the entry
* instead of the currently logged-in user.
*
* @see http://docs.gravityview.co/article/281-the-createdby-merge-tag Read how to use the `{created_by}` merge tag
*
* @since 1.16
*
* @param array $matches Array of Merge Tag matches found in text by preg_match_all
* @param string $text Text to replace
* @param array $form Gravity Forms form array
* @param array $entry Entry array
* @param bool $url_encode Whether to URL-encode output
* @param bool $esc_html Whether to apply `esc_html()` to output
*
* @return string Text, with user variables replaced, if they existed
*/
public function replace_merge_tag($matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false)
{
// If there are no matches OR the Entry `created_by` isn't set or is 0 (no user)
if (empty($entry['created_by'])) {
return $text;
}
// Get the creator of the entry
$entry_creator = new WP_User($entry['created_by']);
foreach ($matches as $match) {
$full_tag = $match[0];
$property = $match[1];
switch ($property) {
/** @since 1.13.2 */
case 'roles':
$value = implode(', ', $entry_creator->roles);
break;
default:
$value = $entry_creator->get($property);
}
$value = $url_encode ? urlencode($value) : $value;
$value = $esc_html ? esc_html($value) : $value;
$text = str_replace($full_tag, $value, $text);
}
unset($entry_creator);
return $text;
}
开发者ID:mgratch,项目名称:GravityView,代码行数:43,代码来源:class-gravityview-field-created-by.php
示例18: map_meta_cap
/**
* editable_roles
* Prevent editing of admins by non-admins.
*
* @since 1.0.0
* @version 1.0.0
**/
function map_meta_cap($caps, $cap, $user_id, $args)
{
switch ($cap) {
case 'edit_user':
case 'remove_user':
case 'promote_user':
if (isset($args[0]) && $args[0] == $user_id) {
break;
} elseif (!isset($args[0])) {
$caps[] = 'do_not_allow';
}
$other = new WP_User(absint($args[0]));
if ($other->has_cap('administrator')) {
if (!current_user_can('administrator')) {
$caps[] = 'do_not_allow';
}
}
break;
case 'delete_user':
case 'delete_users':
if (!isset($args[0])) {
break;
}
$other = new WP_User(absint($args[0]));
if ($other->has_cap('administrator')) {
if (!current_user_can('administrator')) {
$caps[] = 'do_not_allow';
}
}
break;
}
return $caps;
}
开发者ID:sdellow,项目名称:wp-framework,代码行数:40,代码来源:users.php
示例19: wp_install
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '')
{
global $wp_rewrite;
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
populate_options();
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
$guessurl = wp_guess_url();
update_option('siteurl', $guessurl);
// If not a public blog, don't ping.
if (!$public) {
update_option('default_pingback_flag', 0);
}
// Create default user. If the user already exists, the user tables are
// being shared among blogs. Just set the role in that case.
$user_id = username_exists($user_name);
if (!$user_id) {
$random_password = wp_generate_password();
$user_id = wp_create_user($user_name, $random_password, $user_email);
} else {
$random_password = __('User already exists. Password inherited.');
}
$user = new WP_User($user_id);
$user->set_role('administrator');
wp_install_defaults($user_id);
$wp_rewrite->flush_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
wp_cache_flush();
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
}
开发者ID:alx,项目名称:blogsfera,代码行数:34,代码来源:upgrade.php
示例20: test_delete_user
function test_delete_user()
{
$user_id = $this->factory->user->create(array('role' => 'author'));
$user = new WP_User($user_id);
$post = array('post_author' => $user_id, 'post_status' => 'publish', 'post_content' => rand_str(), 'post_title' => rand_str(), 'post_type' => 'post');
// insert a post and make sure the ID is ok
$post_id = wp_insert_post($post);
$this->assertTrue(is_numeric($post_id));
$this->assertTrue($post_id > 0);
$post = get_post($post_id);
$this->assertEquals($post_id, $post->ID);
$post = array('post_author' => $user_id, 'post_status' => 'publish', 'post_content' => rand_str(), 'post_title' => rand_str(), 'post_type' => 'nav_menu_item');
// insert a post and make sure the ID is ok
$nav_id = wp_insert_post($post);
$this->assertTrue(is_numeric($nav_id));
$this->assertTrue($nav_id > 0);
$post = get_post($nav_id);
$this->assertEquals($nav_id, $post->ID);
wp_delete_user($user_id);
$user = new WP_User($user_id);
if (is_multisite()) {
$this->assertTrue($user->exists());
} else {
$this->assertFalse($user->exists());
}
$this->assertNotNull(get_post($post_id));
$this->assertEquals('trash', get_post($post_id)->post_status);
// nav_menu_item is delete_with_user = false so the nav post should remain published.
$this->assertNotNull(get_post($nav_id));
$this->assertEquals('publish', get_post($nav_id)->post_status);
wp_delete_post($nav_id, true);
$this->assertNull(get_post($nav_id));
wp_delete_post($post_id, true);
$this->assertNull(get_post($post_id));
}
开发者ID:plis197715,项目名称:wordpress-develop,代码行数:35,代码来源:wpDeleteUser.php
注:本文中的WP_User类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论