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


PHP get_user_by_email函数代码示例

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


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

示例1: wppb_changeDefaultAvatar

function wppb_changeDefaultAvatar($avatar, $id_or_email, $size, $default, $alt)
{
    global $wpdb;
    /* Get user info. */
    if (is_object($id_or_email)) {
        $my_user_id = $id_or_email->user_id;
    } elseif (is_numeric($id_or_email)) {
        $my_user_id = $id_or_email;
    } elseif (!is_integer($id_or_email)) {
        $user_info = get_user_by_email($id_or_email);
        $my_user_id = $user_info->ID;
    } else {
        $my_user_id = $id_or_email;
    }
    $arraySettingsPresent = get_option('wppb_custom_fields', 'not_found');
    if ($arraySettingsPresent != 'not_found') {
        $wppbFetchArray = get_option('wppb_custom_fields');
        foreach ($wppbFetchArray as $value) {
            if ($value['item_type'] == 'avatar') {
                $customUserAvatar = get_user_meta($my_user_id, 'resized_avatar_' . $value['id'], true);
                if ($customUserAvatar != '' || $customUserAvatar != null) {
                    $avatar = "<img alt='{$alt}' src='{$customUserAvatar}' class='avatar avatar-{$value['item_options']} photo avatar-default' height='{$size}' width='{$size}' />";
                }
            }
        }
    }
    return $avatar;
}
开发者ID:serker72,项目名称:T3S,代码行数:28,代码来源:premium.functions.load.php

示例2: post_submission

 public static function post_submission()
 {
     extract($_POST);
     if (empty($from_user_id) && !empty($from_user_email)) {
         $from_user = get_user_by_email($from_user_email);
         $from_user_id = $from_user->ID;
         if (!$from_user_id) {
             echo 'Failed to find user with email "' . $from_user_email . '". Please check the address and try again.';
             return;
         }
     }
     if (empty($to_user_id) && !empty($to_user_email)) {
         $to_user = get_user_by_email($to_user_email);
         $to_user_id = $to_user->ID;
         if (!$to_user_id) {
             echo 'Failed to find user with email "' . $to_user_email . '". Please check the address and try again.';
             return;
         }
     }
     if (empty($from_user_id) || empty($to_user_id)) {
         echo 'Please select a source user and a target user';
         return;
     }
     bb_merge_users_process($from_user_id, $to_user_id, true);
 }
开发者ID:BrownBox,项目名称:bbconnect-quicklinks,代码行数:25,代码来源:60_merge.class.php

示例3: login

 static function login()
 {
     if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], 'login')) {
         return;
     }
     $user_by_email = get_user_by_email($_POST['email']);
     if (empty($user_by_email)) {
         Kanban::$instance->flash->add('danger', 'Whoops! We can\'t find an account for that email address.');
         wp_redirect($_POST['_wp_http_referer']);
         exit;
     }
     $creds = array();
     $creds['user_login'] = $user_by_email->user_login;
     $creds['user_password'] = $_POST['password'];
     $creds['remember'] = true;
     $user = wp_signon($creds, false);
     if (is_wp_error($user)) {
         Kanban::$instance->flash->add('danger', 'Whoops! That password is incorrect for this email address.');
         wp_redirect($_POST['_wp_http_referer']);
         exit;
     }
     wp_set_current_user($user->ID);
     wp_set_auth_cookie($user->ID);
     wp_redirect(sprintf('/%s/board', Kanban::$slug));
     exit;
 }
开发者ID:vlood,项目名称:kanban-wordpress-plugin,代码行数:26,代码来源:class-user.php

示例4: xtec_settings_wp_head

/**
 * Prints meta info.
 */
function xtec_settings_wp_head()
{
    echo sprintf("<meta name=\"DC.Title\" content=\"%s\"/>\n", get_bloginfo('title'));
    echo sprintf("<meta name=\"DC.Creator\" content=\"%s\"/>\n", get_user_by_email(get_bloginfo('admin_email'))->user_login);
    echo sprintf("<meta name=\"DC.Subject\" scheme=\"eo\" content=\"%s\"/>\n", get_bloginfo('description'));
    echo sprintf("<meta name=\"DC.Language\" content=\"%s\"/>\n", get_bloginfo('language'));
}
开发者ID:ignacioabejaro,项目名称:xtecblocs,代码行数:10,代码来源:xtec-settings.php

示例5: email_exists

/**
 * Checks whether the given email exists.
 *
 * @since 2.1.0
 * @uses $wpdb
 *
 * @param string $email Email.
 * @return bool|int The user's ID on success, and false on failure.
 */
function email_exists($email)
{
    if ($user = get_user_by_email($email)) {
        return $user->ID;
    }
    return false;
}
开发者ID:google-code-backups,项目名称:pumpmyvote,代码行数:16,代码来源:registration.php

示例6: json_basic_auth_handler

/**
 * Plugin Name: JSON Basic Authentication
 * Description: Basic Authentication handler for the JSON API, used for development and debugging purposes
 * Author: WordPress API Team
 * Author URI: https://github.com/WP-API
 * Version: 0.1
 * Plugin URI: https://github.com/WP-API/Basic-Auth
 */
function json_basic_auth_handler($request)
{
    global $wp_json_basic_auth_error;
    $wp_json_basic_auth_error = null;
    // Check that we're trying to authenticate
    if (!isset($_SERVER['PHP_AUTH_USER'])) {
        return $request;
    }
    $username = $_SERVER['PHP_AUTH_USER'];
    $is_email = strpos($username, '@');
    if ($is_email) {
        $ud = get_user_by_email($username);
        $username = $ud->user_login;
    }
    $password = $_SERVER['PHP_AUTH_PW'];
    $user = wp_authenticate($username, $password);
    if ($user) {
        wp_set_current_user($user->ID, $user->user_login);
        wp_set_auth_cookie($user->ID);
        do_action('wp_login', $user->user_login);
    }
    /**
     * In multi-site, wp_authenticate_spam_check filter is run on authentication. This filter calls
     * get_currentuserinfo which in turn calls the determine_current_user filter. This leads to infinite
     * recursion and a stack overflow unless the current function is removed from the determine_current_user
     * filter during authentication.
     */
    if (is_wp_error($user)) {
        $wp_json_basic_auth_error = $user;
        return null;
    }
    $wp_json_basic_auth_error = true;
    return null;
}
开发者ID:gopaulo,项目名称:Basic-Auth,代码行数:42,代码来源:basic-auth.php

示例7: retrieve_password

/**
 * Handles sending password retrieval email to user.
 *
 * @uses $wpdb WordPress Database object
 *
 * @return bool|WP_Error True: when finish. WP_Error on error
 */
function retrieve_password()
{
    global $wpdb;
    $errors = new WP_Error();
    if (empty($_POST['user_login']) && empty($_POST['user_email'])) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
    }
    if (strpos($_POST['user_login'], '@')) {
        $user_data = get_user_by_email(trim($_POST['user_login']));
        if (empty($user_data)) {
            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
        }
    } else {
        $login = trim($_POST['user_login']);
        $user_data = get_userdatabylogin($login);
    }
    do_action('lostpassword_post');
    if ($errors->get_error_code()) {
        return $errors;
    }
    if (!$user_data) {
        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
        return $errors;
    }
    // redefining user_login ensures we return the right case in the email
    $user_login = $user_data->user_login;
    $user_email = $user_data->user_email;
    do_action('retreive_password', $user_login);
    // Misspelled and deprecated
    do_action('retrieve_password', $user_login);
    $allow = apply_filters('allow_password_reset', true, $user_data->ID);
    if (!$allow) {
        return new WP_Error('no_password_reset', __('Password reset is not allowed for this user'));
    } else {
        if (is_wp_error($allow)) {
            return $allow;
        }
    }
    $user_email = $_POST['user_email'];
    $user_login = $_POST['user_login'];
    $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE user_login = %s", $user_login));
    if (empty($user)) {
        return new WP_Error('invalid_key', __('Invalid key'));
    }
    $new_pass = wp_generate_password(12, false);
    do_action('password_reset', $user, $new_pass);
    wp_set_password($new_pass, $user->ID);
    update_usermeta($user->ID, 'default_password_nag', true);
    //Set up the Password change nag.
    $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
    $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
    $message .= site_url() . '/?ptype=affiliate' . "\r\n";
    $title = sprintf(__('[%s] Your new password'), get_option('blogname'));
    $title = apply_filters('password_reset_title', $title);
    $message = apply_filters('password_reset_message', $message, $new_pass);
    if ($message && !wp_mail($user_email, $title, $message)) {
        die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
    }
    return true;
}
开发者ID:annguyenit,项目名称:getdeal,代码行数:67,代码来源:affiliate_login.php

示例8: retrieve_password

/**
 * Handles sending password retrieval email to user.
 *
 * @uses $wpdb WordPress Database object
 *
 * @return bool|WP_Error True: when finish. WP_Error on error
 */
function retrieve_password()
{
    global $wpdb;
    $errors = new WP_Error();
    if (empty($_POST['user_login']) && empty($_POST['user_email'])) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'templatic'));
    }
    if (strpos($_POST['user_login'], '@')) {
        $user_data = get_user_by_email(trim($_POST['user_login']));
        if (empty($user_data)) {
            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'templatic'));
        }
    } else {
        $login = trim($_POST['user_login']);
        $user_data = get_userdatabylogin($login);
    }
    do_action('lostpassword_post');
    if ($errors->get_error_code()) {
        return $errors;
    }
    if (!$user_data) {
        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'templatic'));
        return $errors;
    }
    // redefining user_login ensures we return the right case in the email
    $user_login = $user_data->user_login;
    $user_email = $user_data->user_email;
    do_action('retreive_password', $user_login);
    // Misspelled and deprecated
    do_action('retrieve_password', $user_login);
    $user_email = $_POST['user_email'];
    $user_login = $_POST['user_login'];
    $user = $wpdb->get_row("SELECT * FROM {$wpdb->users} WHERE user_login like \"{$user_login}\" or user_email like \"{$user_login}\"");
    if (empty($user)) {
        return new WP_Error('invalid_key', __('Invalid key', 'templatic'));
    }
    $new_pass = wp_generate_password(12, false);
    do_action('password_reset', $user, $new_pass);
    wp_set_password($new_pass, $user->ID);
    update_usermeta($user->ID, 'default_password_nag', true);
    //Set up the Password change nag.
    $message = '<p><b>Your login Information :</b></p>';
    $message .= '<p>' . sprintf(__('Username: %s', 'templatic'), $user->user_login) . "</p>";
    $message .= '<p>' . sprintf(__('Password: %s', 'templatic'), $new_pass) . "</p>";
    $message .= '<p>You can login to : <a href="' . site_url() . '/?ptype=login' . "\">Login</a> or the URL is :  " . site_url() . "/?ptype=login</p>";
    $message .= '<p>Thank You,<br> ' . get_option('blogname') . '</p>';
    $user_email = $user_data->user_email;
    $user_name = $user_data->user_nicename;
    $fromEmail = get_site_emailId();
    $fromEmailName = get_site_emailName();
    $title = sprintf(__('[%s] Your new password', 'templatic'), get_option('blogname'));
    $title = apply_filters('password_reset_title', $title);
    $message = apply_filters('password_reset_message', $message, $new_pass);
    if (get_option('pttthemes_send_mail') == 'Enable' || get_option('pttthemes_send_mail') == '') {
        templ_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '');
        ///forgot password email
    }
    return true;
}
开发者ID:annguyenit,项目名称:getdeal,代码行数:66,代码来源:registration.php

示例9: email_address_login

function email_address_login($username)
{
    $user = get_user_by_email($username);
    if (!empty($user->user_login)) {
        $username = $user->user_login;
    }
    return $username;
}
开发者ID:Anclock,项目名称:loobobetter,代码行数:8,代码来源:functions.php

示例10: getUsernameByInput

 static function getUsernameByInput($username)
 {
     if (strpos($username, '@') !== false && ($users = get_user_by_email($username))) {
         $username = $users[0]->username;
     } else {
         $username = $username;
     }
     return $username;
 }
开发者ID:pleio,项目名称:rijkshuisstijl,代码行数:9,代码来源:Helpers.php

示例11: email_system

/**
 *  check if the user is inactive
 *  if so we're not sending email
 * 
 * @param type $hook
 * @param type $type
 * @param type $return
 * @param type $params
 * @return boolean
 */
function email_system($hook, $type, $return, $params)
{
    $email = $params['to'];
    $user = get_user_by_email($email);
    if ($user[0]->member_selfdelete == "anonymized") {
        return false;
    }
    return $return;
}
开发者ID:beck24,项目名称:member_selfdelete,代码行数:19,代码来源:hooks.php

示例12: pam_handler

/**
 * Can we allow the user with the credentials to log in?
 * Check stormpath, create the user if they can log in and don't exist
 * Enable the user if they can log in but were waiting for email verification
 * 
 * @param type $credentials
 * @return boolean
 */
function pam_handler($credentials)
{
    // try to authenticate first
    $application = get_application();
    $authResult = $application->authenticate($credentials['username'], $credentials['password']);
    $account = $authResult->account;
    if (!$account || strtolower($account->status) != 'enabled') {
        return false;
    }
    // we need to search hidden users too
    // in case of email confirmation disabling
    $show_hidden = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    // we have an account and it's enabled
    // see if we have a matching account here
    // check if logging in with email address
    if (strpos($credentials['username'], '@') !== false) {
        $users = get_user_by_email($credentials['username']);
        $user = $users[0];
    } else {
        $user = get_user_by_username($credentials['username']);
    }
    // custom context gives us permission to do this
    elgg_push_context('stormpath_validate_user');
    // if we don't have a user we need to create one
    if (!$user) {
        $user = new \ElggUser();
        $user->username = preg_replace("/[^a-zA-Z0-9]/", "", $account->username);
        $user->email = $account->email;
        $user->name = $account->fullName;
        $user->access_id = ACCESS_PUBLIC;
        $user->salt = _elgg_generate_password_salt();
        $user->password = generate_user_password($user, $credentials['password']);
        $user->owner_guid = 0;
        // Users aren't owned by anyone, even if they are admin created.
        $user->container_guid = 0;
        // Users aren't contained by anyone, even if they are admin created.
        $user->language = get_current_language();
        $user->save();
        $user->__stormpath_user = $account->href;
        elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
        // Turn on email notifications by default
        set_user_notification_setting($user->getGUID(), 'email', true);
    }
    // see if we need to enable/verify the user
    if (!$user->isEnabled() && in_array($user->disable_reason, array('stormpath_new_user', 'uservalidationbyemail_new_user'))) {
        $user->enable();
        $user->__stormpath_user = $account->href;
        elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
    }
    elgg_pop_context();
    access_show_hidden_entities($show_hidden);
    if ($user && $user->isEnabled()) {
        return true;
    }
    return false;
}
开发者ID:arckinteractive,项目名称:elgg_stormpath,代码行数:65,代码来源:start.php

示例13: webbird_allow_email_login

function webbird_allow_email_login($user, $username, $password)
{
    if (is_email($username)) {
        $user = get_user_by_email($username);
        if ($user) {
            $username = $user->user_login;
        }
    }
    return wp_authenticate_username_password(null, $username, $password);
}
开发者ID:WebBirdWebIntegrators,项目名称:eagle-wp-theme,代码行数:10,代码来源:wordpress-admin.php

示例14: getUser

 public function getUser($login)
 {
     if (strpos($login, '@') !== false) {
         $users = get_user_by_email($login);
         $user = $users[0];
     } else {
         $user = get_user_by_username($login);
     }
     return $user;
 }
开发者ID:Pleio,项目名称:pleio_rest,代码行数:10,代码来源:UserCredentialsStorage.php

示例15: bcs_el_login_with_email

function bcs_el_login_with_email($user, $username, $password)
{
    if (is_email($username)) {
        $user = get_user_by_email($username);
        if ($user) {
            $username = $user->user_login;
        }
    }
    return wp_authenticate_username_password(null, $username, $password);
}
开发者ID:ChristianWhiting,项目名称:DIY,代码行数:10,代码来源:email_login.php


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