Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function vf_get_user() {
- global $current_user, $wp_roles;
- if (!function_exists('get_currentuserinfo'))
- require_once ABSPATH . WPINC . '/pluggable.php';
- get_currentuserinfo();
- $user = array();
- if ($current_user->ID != '') {
- $user['uniqueid'] = $current_user->ID;
- $user['name'] = $current_user->display_name;
- $user['email'] = $current_user->user_email;
- $user['photourl'] = ''; //
- $user['wp_nonce'] = wp_create_nonce('log-out');
- // Do some fudgery to grab the photo url.
- try {
- $avatar = new SimpleXMLElement(get_avatar($current_user->ID));
- if (isset($avatar['src']))
- $user['photourl'] = (string)$avatar['src'];
- } catch (Exception $Ex) {
- }
- // Add the user's roles to the SSO.
- if (isset($current_user->roles)) {
- if (!isset( $wp_roles ) )
- $wp_roles = new WP_Roles();
- $role_names = $wp_roles->role_names;
- $roles = array();
- foreach ((array)$current_user->roles as $role_slug) {
- // Add the role slug.
- $roles[] = $role_slug;
- // Add the role name if it's different from the slug.
- if (isset($role_names[$role_slug])) {
- $role_name = $role_names[$role_slug];
- if (strcasecmp($role_name, $role_slug) !== 0) {
- $roles[] = str_replace(',', ' ', $role_name);
- }
- }
- }
- $user['roles'] = implode(',', array_unique($roles));
- } else {
- $user['roles'] = null;
- }
- // $user['_user'] = $current_user;
- }
- // Allow other plugins to modify the user.
- $user = apply_filters('vf_get_user', $user);
- return $user;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement