dozent_get_the_user( int|string|null $user = null )
Get the user by field or from the query_var, from Dozent User page
Description
The function will return the user automatically from the profile page, or wheyn found the query_var = dozent_profile_username If pass null in the parameter, it will try to return the user from the profile user. If fail, finally it will return the currently logged in user.
Parameters
- $user
-
(int|string|null) (Optional) User ID | User Object | E-Mail | Nice Name | Login
Default value: null
Return
(bool|WP_User)
Source
File: includes/user-functions.php
function dozent_get_the_user( $user = null ) { if ( $user instanceof \Dozent\UserData){ return $user; } if ( $user ) { if ( is_object( $user ) ) { if ( $user instanceof WP_User ) { return $user; } elseif ( ! empty( $user->ID ) ) { $_user = get_userdata( $user->ID ); return $_user; } } if ( is_numeric( $user ) ) { $_user = get_userdata( $user ); return $_user; } elseif ( is_email( $user ) ) { $_user = get_user_by_email( $user ); return $_user; } else { $user = get_user_by( 'slug', $user ); if ( ! $user ) { $user = get_user_by( 'login', $user ); } return $user; } } $username = get_query_var( 'dozent_profile_username' ); if ( $username ) { return get_user_by( 'slug', $username ); } $user = wp_get_current_user(); return $user; }
Changelog
Version | Description |
---|---|
DozentLMS 1.0.0 | Introduced. |