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
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | 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. |