當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。