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


PHP WP_User::init方法代码示例

本文整理汇总了PHP中WP_User::init方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_User::init方法的具体用法?PHP WP_User::init怎么用?PHP WP_User::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_User的用法示例。


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

示例1:

 function get_user_by($field, $value)
 {
     $userdata = WP_User::get_data_by($field, $value);
     if (!$userdata) {
         return false;
     }
     $user = new WP_User();
     $user->init($userdata);
     return $user;
 }
开发者ID:sevir,项目名称:toffy-lite,代码行数:10,代码来源:wp_igniter.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: _getWPUser

 private function _getWPUser($id)
 {
     $userdata = WP_User::get_data_by('login', $id);
     if (!$userdata) {
         return false;
     }
     $user = new WP_User();
     $user->init($userdata);
     return $user;
 }
开发者ID:jelicanin,项目名称:Docs-to-WordPress,代码行数:10,代码来源:docs-to-wp.php

示例4: xfac_user_getUserByApiData

function xfac_user_getUserByApiData($root, $xfUserId)
{
    $userdata = xfac_user_getUserDataByApiData($root, $xfUserId);
    if (empty($userdata)) {
        return false;
    }
    $user = new WP_User();
    $user->init($userdata);
    return $user;
}
开发者ID:billyprice1,项目名称:bdApi,代码行数:10,代码来源:user.php

示例5: getUser

 public static function getUser($jwt, $encodedJWT)
 {
     global $wpdb;
     $sql = 'SELECT u.*
             FROM ' . $wpdb->auth0_user . ' a
             JOIN ' . $wpdb->users . ' u ON a.wp_id = u.id
             WHERE a.auth0_id = %s;';
     $userRow = $wpdb->get_row($wpdb->prepare($sql, $jwt->sub));
     if (is_null($userRow)) {
         $domain = WP_Auth0_Options::get('domain');
         $response = WP_Auth0_Api_Client::get_user($domain, $encodedJWT, $jwt->sub);
         if ($response['response']['code'] != 200) {
             return null;
         }
         $creator = new WP_Auth0_UserCreator();
         if ($creator->tokenHasRequiredScopes($jwt)) {
             $auth0User = $jwt;
         } else {
             $auth0User = json_decode($response['body']);
         }
         try {
             $user_id = $creator->create($auth0User, $encodedJWT);
             do_action('auth0_user_login', $user_id, $response, true, $encodedJWT, null);
             return new WP_User($user_id);
         } catch (WP_Auth0_CouldNotCreateUserException $e) {
             return null;
         } catch (WP_Auth0_RegistrationNotEnabledException $e) {
             return null;
         }
         return null;
     } elseif ($userRow instanceof WP_Error) {
         self::insertAuth0Error('findAuth0User', $userRow);
         return null;
     } else {
         $user = new WP_User();
         $user->init($userRow);
         do_action('auth0_user_login', $user->ID, $response, false, $encodedJWT, null);
         return $user;
     }
 }
开发者ID:james-fitzgerald,项目名称:wp-auth0,代码行数:40,代码来源:WP_Auth0_UsersRepo.php

示例6: findAuth0User

 private static function findAuth0User($id)
 {
     global $wpdb;
     $sql = 'SELECT u.*
             FROM ' . $wpdb->auth0_user . ' a
             JOIN ' . $wpdb->users . ' u ON a.wp_id = u.id
             WHERE a.auth0_id = %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:erik-pantheon,项目名称:wp-auth0,代码行数:18,代码来源:WP_Auth0.php

示例7: getUserBy

 public static function getUserBy($field, $value, $focus = false)
 {
     if (class_exists(InnThemeUser::class) && method_exists(InnThemeUser::class, 'getUserBy')) {
         InnThemeUser::getUserBy($field, $value, $focus);
     }
     static $cache = [];
     $cacheID = $field . $value . $focus;
     if (!$focus && isset($cache[$cacheID])) {
         return $cache[$cacheID];
     }
     $userdata = \WP_User::get_data_by($field, $value);
     if (!$userdata) {
         $cache[$cacheID] = false;
         return false;
     }
     $user = new \WP_User();
     $user->init($userdata);
     $cache[$cacheID] = $user;
     return $user;
 }
开发者ID:kmvan,项目名称:poil10n,代码行数:20,代码来源:Api.php

示例8:

 function get_user_by($field, $value)
 {
     $piereg = get_option('pie_register');
     if ('email' == $field && PieMemberRegister::$instance->during_user_creation) {
         return false;
     }
     $userdata = WP_User::get_data_by($field, $value);
     if (!$userdata) {
         return false;
     }
     $user = new WP_User();
     $user->init($userdata);
     return $user;
 }
开发者ID:hoonio,项目名称:PhoneAfrika,代码行数:14,代码来源:pie-register.php

示例9:

 /**
  * Retrieve user info by a given field
  *
  * @since 2.8.0
  *
  * @param string $field The field to retrieve the user with. id | slug | email | login
  * @param int|string $value A value for $field. A user ID, slug, email address, or login name.
  * @return bool|object False on failure, WP_User object on success
  */
 function get_user_by($field, $value)
 {
     if ('id' === $field && (int) $value && get_current_user_id() === (int) $value) {
         return wp_get_current_user();
     }
     $userdata = WP_User::get_data_by($field, $value);
     if (!$userdata) {
         return false;
     }
     $user = new WP_User();
     $user->init($userdata);
     return $user;
 }
开发者ID:dcatontopcorp,项目名称:wordpress,代码行数:22,代码来源:pluggable.php

示例10:

 function get_user_by($field, $value)
 {
     global $xt_during_user_creation;
     if ('email' == $field && $xt_during_user_creation) {
         return false;
     }
     $userdata = WP_User::get_data_by($field, $value);
     if (!$userdata) {
         return false;
     }
     $user = new WP_User();
     $user->init($userdata);
     return $user;
 }
开发者ID:aspirin,项目名称:wp-xintaoke,代码行数:14,代码来源:wp-xintaoke.php

示例11:

 function get_user_by($field, $value)
 {
     $obj = c2c_AllowMultipleAccounts::$instance;
     if ('email' == $field && $obj->during_user_creation && !$obj->has_exceeded_limit($value)) {
         return false;
     }
     $userdata = WP_User::get_data_by($field, $value);
     if (!$userdata) {
         return false;
     }
     $user = new WP_User();
     $user->init($userdata);
     return $user;
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:14,代码来源:allow-multiple-accounts.php


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