wordpress get username
To get the current user's username in WordPress, you can use the following code:
$current_user = wp_get_current_user();
$username = $current_user->user_login;
Explanation:
1. wp_get_current_user()
: This function returns the current user object.
2. $current_user
: We store the current user object in this variable.
3. $username = $current_user->user_login;
: We retrieve the username from the current user object and store it in the $username variable.