本文整理汇总了PHP中get_user_id_from_string函数的典型用法代码示例。如果您正苦于以下问题:PHP get_user_id_from_string函数的具体用法?PHP get_user_id_from_string怎么用?PHP get_user_id_from_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_user_id_from_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: msxmlrpc_create_blog
/**
* Creates a new blog calling wpmu_create_blog
* the wpmu_create_blog parameters are:
* $domain The domain of the new blog.
* $path The path of the new blog.
* $title The title of the new blog.
* $user_id The user id of the user account who will be the blog admin. (you can use an email instead of the user_id. If so, a new user will be created)
* $meta Other meta information.
* $site_id The site_id of the blog to be created.
*
* @param array $args Array with username, password and wpmu_create_blog function parameters
* @return mixed The new blog id or an error message
*/
function msxmlrpc_create_blog($args)
{
$parameters = check_arguments($args);
if (!is_array($parameters)) {
return $parameters;
}
// if the user_id is the user's e-mail
if (!is_int($parameters['user_id'])) {
if (!($user_id = get_user_id_from_string($parameters['user_id']))) {
$error = wpmu_validate_user_signup($parameters['path'], $parameters['user_id']);
if (is_wp_error($error)) {
return new IXR_Error(500, $error->get_error_message());
}
$user_id = wpmu_create_user($parameters['path'], wp_generate_password(), $parameters['user_id']);
}
$parameters['user_id'] = $user_id;
}
if (get_blog_id($parameters['domain'], $parameters['path']) !== false) {
return new IXR_Error(500, __("Site already exists."));
}
if (!isset($parameters['meta'])) {
$parameters['meta'] = "";
}
if (!isset($parameters['site_id'])) {
$parameters['site_id'] = 1;
}
return wpmu_create_blog($parameters['domain'], $parameters['path'], $parameters['title'], $parameters['user_id'], $parameters['meta'], $parameters['site_id']);
}
示例2: 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
}
示例3: toolbar_evaluation
function toolbar_evaluation($wp_admin_bar)
{
if (is_admin()) {
return false;
}
global $wpdb;
$eval_table_name = "wp_seufolios_evaluations";
$current_user = wp_get_current_user();
$user_role = get_the_user_role($current_user);
$admin_id = get_user_id_from_string(get_blog_option($current_blog->blog_id, 'admin_email'));
$submit = "profid={$current_user->id}" . "&" . "studentid={$admin_id}" . "&";
$sql = "SELECT answers FROM {$eval_table_name} WHERE profid={$current_user->id} and studentid={$admin_id}";
$results = $wpdb->get_results($sql);
if (count($results) > 0) {
$submit .= $results[0]->answers;
}
if ($user_role == 'Professor' || $user_role == 'Super_admin') {
$plugin_url = plugins_url() . '/seufolios/';
$args = array('id' => 'seufolios-evaluation', 'title' => 'Evaluate', 'href' => 'http://ryanhoover.net', 'meta' => array('onclick' => "insertIframe(\"{$plugin_url}\", \"{$submit}\"); return false;"));
$wp_admin_bar->add_node($args);
}
}
示例4: is_user_spammy
/**
* Check to see whether a user is marked as a spammer, based on username
*
* @since MU
* @uses get_current_user_id()
* @uses get_user_id_from_string()
*
* @param string $username
* @return bool
*/
function is_user_spammy($username = 0)
{
if ($username == 0) {
$user_id = get_current_user_id();
} else {
$user_id = get_user_id_from_string($username);
}
$u = new WP_User($user_id);
return isset($u->spam) && $u->spam == 1;
}
示例5: td_bpxps_xprofile_shortcode
function td_bpxps_xprofile_shortcode($attributes)
{
global $wpdb;
if (empty($attributes['field'])) {
return false;
}
extract($attributes);
$urlWithOutSlash = 'http://' . $_SERVER['HTTP_HOST'];
$thisUserId = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->users} WHERE user_url = %s LIMIT 1", $urlWithOutSlash));
// $user_id = (isset($user)) ? $user : false;
$user_id = $thisUserId;
global $bp;
if (!empty($user_id) && intval($user_id) === 0) {
// shortcode-defined username
$user_id = get_user_id_from_string(get_blog_option($thisblog, 'admin_email'));
}
if (isset($user) && $user == 'displayed' || empty($user_id) && isset($bp->displayed_user->id)) {
// On profile page, show the displayed user's information
$user_id = $bp->displayed_user->id;
}
global $post;
if (isset($user) && $user == 'author' || empty($user_id) && !empty($post->post_author)) {
// On author or single post page, show the author's information
$user_id = $post->post_author;
}
if (isset($user) && $user == 'current' || empty($user_id) && is_user_logged_in()) {
// Show the currently logged in user's information
$user_id = get_current_user_id();
}
if (empty($user_id)) {
return false;
}
return xprofile_get_field_data($field, $user_id);
}
示例6: _import_gplus_item
/**
* Binds G+ activity item to WP post.
* Skips import if the item has already been imported.
*/
private function _import_gplus_item($item, $opts = array())
{
if (!$item) {
return false;
}
$feed_id = @$item['actor']['id'];
$item_id = @$item['object']['url'];
if (!$item_id) {
return false;
}
// Invalid data, no point carrying on...
if ($this->_is_imported($item_id)) {
return false;
}
// Item already present.
if (!$this->_is_linked_article($item)) {
$title = @$item['title'];
$content = @$item['object']['content'] . $this->_item_attachments_to_html(@$item['object']['attachments']);
} else {
$result = $this->_parse_linked_article_item($item);
$title = $result['title'];
$content = $result['content'];
}
// Check hashtags
if (@$opts['hashtags'] && !$this->_has_hashtags($content, $opts['hashtags'])) {
return false;
}
// We require a hashtag to import, but found none.
$author = get_userdatabylogin(@$opts['post_author_login']);
$author_id = @$author->ID ? $author->ID : false;
if (!$author_id) {
// No author, assign to admin
global $blog_id;
$author_id = get_user_id_from_string(get_blog_option($blog_id, 'admin_email'));
}
$detected_hashtags = @$opts['auto_hashtag'] || @$opts['format_to_hashtag'] ? $this->_detect_hashtags($content) : array();
$post = array('post_title' => $title, 'post_content' => $content, 'post_type' => $this->_data->get_option('gplus_post_no_publish') ? 'wdgpo_imported_post' : 'post', 'post_date' => date("Y-m-d h:i:s", strtotime($item['published'])), 'post_status' => 'publish', 'post_author' => $author_id);
if (@$opts['post_category']) {
$post['post_category'] = array($opts['post_category']);
}
// Save post
$post_id = wp_insert_post($post);
// Update tags, formats and metas.
if ($post_id) {
update_post_meta($post_id, 'wdgpo_gplus_feed_id', $feed_id);
update_post_meta($post_id, 'wdgpo_gplus_item_id', $item_id);
update_post_meta($post_id, 'wdgpo_gplus_author', @$item['actor']);
$tags = array();
if (@$opts['post_tags']) {
$tags = $opts['post_tags'];
}
if (@$opts['auto_tag']) {
$tags[] = preg_replace('~[^-_.a-zA-Z0-9 ]~', '-', @$item['actor']['displayName']);
}
if (@$opts['auto_hashtag']) {
array_splice($tags, count($tags), 0, $detected_hashtags);
}
if ($tags) {
wp_set_post_tags($post_id, $tags);
}
if (@$opts['post_format'] && !@$opts['format_to_hashtag']) {
set_post_format($post_id, $opts['post_format']);
} else {
if (@$opts['format_to_hashtag']) {
foreach ($opts['format_to_hashtag'] as $format => $hashtag_mappings) {
if (!$hashtag_mappings) {
continue;
}
if (!$this->_has_hashtags($content, $hashtag_mappings)) {
continue;
}
set_post_format($post_id, $format);
break;
}
}
}
// else no post format to assign...
}
if (defined('BP_VERSION') && $this->_data->get_option('gplus_post_bp_activities')) {
$args = array('action' => $title, 'content' => $content, 'component' => 'wdgpo_activities', 'type' => 'wdgpo_activity', 'item_id' => $post_id, 'secondary_item_id' => $post_id);
$res = bp_activity_add($args);
}
return $post_id ? 1 : 0;
}
示例7: is_user_spammy
function is_user_spammy($username = 0)
{
if ($username == 0) {
global $current_user;
$user_id = $current_user->ID;
} else {
$user_id = get_user_id_from_string($username);
}
$u = new WP_User($user_id);
if ($u->spam == 1) {
return true;
}
return false;
}
示例8: wppb_check_for_unapproved_user
function wppb_check_for_unapproved_user($data, $what)
{
$retArray = array(0 => '', 1 => '');
$retMessage = '';
$messageNo = '';
$wppb_generalSettings = get_option('wppb_general_settings');
if ($wppb_generalSettings['adminApproval'] == 'yes') {
if ($what == 'user_email') {
require_once ABSPATH . WPINC . '/ms-functions.php';
$userID = get_user_id_from_string($data);
} else {
$user = get_user_by('login', $data);
$userID = $user->ID;
}
if (wp_get_object_terms($userID, 'user_status')) {
$retMessage = '<strong>' . __('ERROR', 'profilebuilder') . '</strong>: ' . __('Your account has to be confirmed by an administrator before you can use the "Password Reset" feature.', 'profilebuilder');
$retMessage = apply_filters('wppb_recover_password_unapporved_user', $retMessage);
$messageNo = '6';
}
}
return $retArray = array(0 => $retMessage, 1 => $messageNo);
}
示例9: ds_feed_login
function ds_feed_login() {
global $current_blog, $blog_id;
$credentials = array();
$credentials['user_login'] = $_SERVER['PHP_AUTH_USER'];
$credentials['user_password'] = $_SERVER['PHP_AUTH_PW'];
$user = wp_signon( $credentials ); //if this creates WP_User, the next 3 lines are redundant
$user_id = get_user_id_from_string( $user->user_login );
if ( is_wp_error( $user ) ||
// "Members Only"
( ( '-2' == $current_blog->public ) && ( !is_user_member_of_blog( $user_id, $blog_id ) ) && !is_super_admin( $user_id ) ) ||
// TODO "Admins Only" - members still see feeds need a new ms-function is_site_admin( $user_id, $blog_id )
( ( '-3' == $current_blog->public )
//&& !is_site_admin( $user_id, $blog_id ) //this function doesn't exist
&& ( !is_user_member_of_blog( $user_id, $blog_id ) )
&& !is_super_admin( $user_id ) )
)
{
header( 'WWW-Authenticate: Basic realm="' . $_SERVER['SERVER_NAME'] . '"' );
header( 'HTTP/1.0 401 Unauthorized' );
die();
}
}
示例10: admin_notice
/**
* Add notice to admin dashboard for security reasons
*
*/
function admin_notice()
{
/* IWP */
if (defined('MULTISITE') && MULTISITE == true) {
global $blog_id;
$user_id_from_email = get_user_id_from_string(get_blog_option($blog_id, 'admin_email'));
$details = get_userdata($user_id_from_email);
$username = $details->user_login;
} else {
$current_user = wp_get_current_user();
$username = $current_user->data->user_login;
}
$iwp_client_activate_key = get_option('iwp_client_activate_key');
//check BWP
$bwp = get_option("bit51_bwps");
$notice_display_URL = admin_url();
if (!empty($bwp)) {
//$bwpArray = @unserialize($bwp);
if ($bwp['hb_enabled'] == 1) {
$notice_display_URL = get_option('home');
}
}
$notice_display_URL = rtrim($notice_display_URL, '/') . '/';
echo '<div class="updated" style="text-align: center;"><p style="color: green; font-size: 14px; font-weight: bold;">Add this site to IWP Admin panel</p><p>
<table border="0" align="center">';
if (!empty($iwp_client_activate_key)) {
echo '<tr><td align="right">WP-ADMIN URL:</td><td align="left"><strong>' . $notice_display_URL . '</strong></td></tr>
<tr><td align="right">ADMIN USERNAME:</td><td align="left"><strong>' . $username . '</strong> (or any admin id)</td></tr>
<tr><td align="right">ACTIVATION KEY:</td><td align="left"><strong>' . $iwp_client_activate_key . '</strong></td></tr>';
} else {
echo '<tr><td align="center">Please deactivate and then activate InfiniteWP Client plugin.</td></tr>';
}
echo '</table>
</p></div>';
}
示例11: admin_notice
/**
* Add notice to admin dashboard for security reasons
*
*/
function admin_notice()
{
/* IWP */
if (defined('MULTISITE') && MULTISITE == true) {
global $blog_id;
$user_id_from_email = get_user_id_from_string(get_blog_option($blog_id, 'admin_email'));
$details = get_userdata($user_id_from_email);
$username = $details->user_login;
} else {
$current_user = wp_get_current_user();
$username = $current_user->data->user_login;
}
$iwp_client_activate_key = get_option('iwp_client_activate_key');
//check BWP
$bwp = get_option("bit51_bwps");
$notice_display_URL = admin_url();
if (!empty($bwp)) {
//$bwpArray = @unserialize($bwp);
if ($bwp['hb_enabled'] == 1) {
$notice_display_URL = get_option('home');
}
}
$notice_display_URL = rtrim($notice_display_URL, '/') . '/';
echo '<div class="updated" style="text-align: center; display:block !important; "><p style="color: green; font-size: 14px; font-weight: bold;">Add this site to IWP Admin panel</p><p>
<table border="0" align="center" cellpadding="5">';
if (!empty($iwp_client_activate_key)) {
echo '<tr><td align="right">WP-ADMIN URL:</td><td align="left"><strong>' . $notice_display_URL . '</strong></td></tr>
<tr><td align="right">ADMIN USERNAME:</td><td align="left"><strong>' . $username . '</strong> (or any admin id)</td></tr>
<tr><td align="right">ACTIVATION KEY:</td><td align="left"><strong>' . $iwp_client_activate_key . '</strong></td></tr>
<tr id="copy_at_once"><td align="right">To quick add, copy this</td><td align="left" style="position:relative;"><input type="text" style="width:295px;" class="read_creds" readonly value="' . $notice_display_URL . '|^|' . $username . '|^|' . $iwp_client_activate_key . '" /></td></tr>
<tr class="only_flash"><td></td><td align="left" style="position:relative;"><div id="copy_details" style="background:#008000;display: inline-block;padding: 4px 10px;border-radius: 5px;color:#fff;font-weight:600;cursor:pointer;">Copy details</div><span class="copy_message" style="display:none;margin-left:10px;color:#008000;">Copied :)</span></td></tr>
<script type="text/javascript">
var hasFlash = function() {
return (typeof navigator.plugins == "undefined" || navigator.plugins.length == 0) ? !!(new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) : navigator.plugins["Shockwave Flash"];
};
var onhoverMsg = "<span class=\\"aftercopy_instruction\\" style=\\"position: absolute;top: 32px;left:20px;background:#fff;border:1px solid #000;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;padding:2px;margin:2px;text-align:center;\\">Paste this in any field in the Add Website dialogue in the InfiniteWP admin panel.</span>";
if(typeof hasFlash() != "undefined"){
var client = new ZeroClipboard( jQuery("#copy_details") );
client.on( "ready", function(event) {
// console.log( "movie is loaded" );
client.on( "copy", function(event) {
event.clipboardData.setData("text/plain", jQuery(".read_creds").val());
} );
client.on( "aftercopy", function(event) {
// console.log("Copied text to clipboard: " + event.data["text/plain"]);
jQuery(".copy_message").show();
setTimeout(\'jQuery(".copy_message").hide();\',1000);
} );
} );
client.on( "error", function(event) {
ZeroClipboard.destroy();
} );
jQuery("#copy_at_once").hide();
jQuery("#copy_details").mouseenter(function(){jQuery(onhoverMsg).appendTo(jQuery(this).parent());}).mouseleave(function(){jQuery(".aftercopy_instruction").remove();});
}else{
jQuery(".only_flash").remove();
jQuery(".read_creds").click(function(){jQuery(this).select();});
jQuery(".read_creds").mouseenter(function(e){jQuery(onhoverMsg).appendTo(jQuery(this).parent());}).mouseleave(function(){jQuery(".aftercopy_instruction").remove();});
}
</script>';
} else {
echo '<tr><td align="center">Please deactivate and then activate InfiniteWP Client plugin.</td></tr>';
}
echo '</table>
</p></div>';
}
示例12: for_user
public static function for_user($kwargs)
{
if (isset($kwargs['user_id'])) {
$userid = $kwargs['user_id'];
} else {
if (isset($kwargs['user_email'])) {
$userid = get_user_id_from_string($kwargs['user_email']);
if ($userid === 0) {
throw new JsonableException(__("I don't know that email address", 'mtv'));
}
} else {
if (isset($kwargs['user_login'])) {
$userid = get_user_id_from_string($kwargs['user_login']);
if ($userid === 0) {
throw new JsonableException(__("I don't know that username", 'mtv'));
}
} else {
throw new NotImplementedException();
}
}
}
$class = get_called_class();
$blogdata = get_blogs_of_user($userid);
$sites = new $class();
if (!empty($blogdata)) {
foreach ($blogdata as $b) {
$site = new static::$model();
$site->reload($b);
$sites->add($site);
}
}
return $sites;
}
示例13: ds_feed_login
function ds_feed_login()
{
global $current_blog, $blog_id;
$credentials = array();
$credentials['user_login'] = $_SERVER['PHP_AUTH_USER'];
$credentials['user_password'] = $_SERVER['PHP_AUTH_PW'];
$user = wp_signon($credentials);
//if this creates WP_User, the next 3 lines are redundant
$user_id = get_user_id_from_string($user->user_login);
if (is_wp_error($user) || '-2' == $current_blog->public && !is_user_member_of_blog($user_id, $blog_id) && !is_super_admin($user_id) || '-3' == $current_blog->public && !is_user_member_of_blog($user_id, $blog_id) && !is_super_admin($user_id)) {
header('WWW-Authenticate: Basic realm="' . $_SERVER['SERVER_NAME'] . '"');
header('HTTP/1.0 401 Unauthorized');
die;
}
}
示例14: testGetUserIdFromString
function testGetUserIdFromString()
{
_set_users_of_blog(array(array('ID' => 1, 'user_login' => "admin", 'user_email' => "user@example.com")));
$this->assertNull(get_user_id_from_string('non-user@example.com'));
$this->assertEquals(get_user_id_from_string('user@example.com'), 1);
}
示例15: authorinfo
function authorinfo()
{
$blog_admin_email = function_exists('get_blog_option') ? get_blog_option($this->current_blog_var->blog_id, 'admin_email') : get_option('admin_email');
$blog_admin_info = get_user_by('email', $blog_admin_email);
$blog_owner_id = function_exists('get_user_id_from_string') ? get_user_id_from_string($blog_admin_email) : $blog_admin_info->ID;
$authordata = get_userdata($blog_owner_id);
return $authordata;
}