wordpress get username
$current_user = wp_get_current_user();
echo($current_user->user_login);
wordpress get username
$current_user = wp_get_current_user();
echo($current_user->user_login);
get_the_id wordpress
function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$post = get_post();
return ! empty( $post ) ? $post->ID : false;
}
wordpress get user by id
$user_obj = get_user_by('id', 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 );
}
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.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us