本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}