Answers for "get user by id wordpress"

PHP
1

wordpress get username

$current_user = wp_get_current_user();
echo($current_user->user_login);
Posted by: Guest on January-29-2021
0

get_the_id wordpress

function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
    $post = get_post();
    return ! empty( $post ) ? $post->ID : false;
}
Posted by: Guest on October-26-2020
1

wordpress get user by id

$user_obj = get_user_by('id', 1);
Posted by: Guest on June-08-2021
1

how to display user id from a function on a wordpress page

function get_current_user_id() {
    if ( ! function_exists( 'wp_get_current_user' ) ) {
        return 0;
    }
    $user = wp_get_current_user();
    return ( isset( $user->ID ) ? (int) $user->ID : 0 );
}
Posted by: Guest on September-22-2020
0

from user id to user role wordpress

$user_meta = get_userdata( $user_id );

$user_roles = $user_meta->roles; // array with all the roles the user is part of.
Posted by: Guest on October-14-2020

Code answers related to "get user by id wordpress"

Browse Popular Code Answers by Language