Have you tried to go with the “Safe usage” alternative given in the commented section?
I honestly don’t have any experience with wp_get_current_user()
, since I never use it, but anyhow, this ought to work:
global $current_user;
echo 'Username: ' . $current_user->user_login . '<br />';
echo 'User email: ' . $current_user->user_email . '<br />';
echo 'User first name: ' . $current_user->user_firstname . '<br />';
echo 'User last name: ' . $current_user->user_lastname . '<br />';
echo 'User display name: ' . $current_user->display_name . '<br />';
echo 'User ID: ' . $current_user->ID;
wp_get_current_user()
should do the same, as it is nothing but a wrapper for the first two lines above, nonetheless, the above has got to work.
Related Posts:
- Return all users with a specific meta key
- get_users is expecting unserialized meta_value
- How to get the user description with get_users?
- Is a user_meta research case-sensitive or not
- Randomize Users
- How get meta from all users?
- get random users each time based on the meta key
- Storing data to database and user registration
- How to get user meta value in wordpress
- user_login vs. user_nicename
- how to get list of all users and their metadata
- How to make a custom column on the Users admin screen sortable?
- How to get last login Access Date and time
- Getting all user metadata from user
- Extending WP_User class and using this sub-class during the whole lifecycle
- Show Biographical Info while creating new user
- wp_get_current_user in custom file returns 0
- Is there a limit to the length/size of serialized data that can be stored as user meta?
- Hide a user from WordPress
- How to get top 10 user is based on user meta value
- update_user_meta adding new rows in db for same key
- What is the meta-box-order_post_hash used for?
- Delete user from frontend
- User meta conventions / name registry, for social media links
- Memory usage for scalable usermeta queries
- Getting $user_id for the_author_meta outside the loop in multisite
- How to insert new element to existing array in usermeta?
- Select Multiple meta_value from WP DB; Single Query
- Distinguish profile user and admin user IDs / get ID of user being edited
- Get all user meta by meta key instead of ID
- Average Account Age
- WordPress User Meta & ChromePHP or other way to debug/view php variables
- How to keep users unique id stored in session in addition to IP in WordPress plugin?
- Showing all users who match 2 meta fields with current user
- Force a user’s posts category
- update_user_meta() not working
- How to display user’s avatar on their profile page?
- Is it possible to read a result if wp_update_user or update_user_meta fails?
- Prevent update of custom user profile meta field on the front end after 1st entry
- User last login and user last visit problem
- update_user_meta after wordpress in action hooks
- Users create/join groups
- trying to determine if meta value exists for user and if not auto submit gravity form to redirect
- get_user_meta returning empty when it’s NOT empty
- Multiple meta values for one meta key
- When is a user’s meta data table loaded?
- Display and Update User Custom Meta via user-edit.php
- How to list users by custom field?
- users and usermeta table
- WordPress REST API and User meta data
- Gather posts into a cart/lightbox and share with another user
- Get user_meta values for a user for an array of meta_keys?
- Displaying field value in new column in users view on wordpress
- “the_author_meta(‘url’)” not working inside “href”
- Assign random (and unique) user meta upon registration
- How to add to a user_meta field (append)
- editing usermeta when field is an array
- Display the line breaks in user bio without using html
- How to order custom fields in the user profile (admin area)
- How to get user ID’s from multiple usernames?
- If logged in user views his profile page
- Get the users that my following users are following
- Getting a users username in get_user_meta
- Updating user meta on save post
- How to get its meta_value of a specific meta_key within wp_usermeta
- get_users with Serialized Custom Meta Value
- Update user meta array using foreach
- Can’t get the user_meta correctly
- WP_User_Query not searching
- Uses for function: wp_update_user
- Save custom field types with this function…?
- delete_user_meta from a foreach results page
- Reading additional fields in PMPro
- Get UserInfo from WordPress
- Adding user metadata to all users
- Export WordPress User Meta to CSV/Excel
- Display current user metadata on WordPress page
- Existing user_meta fields not updated
- get_the_author_meta i want to write in a loop
- show user based on user_meta
- REST_query_vars for users
- Get all data form users and users metakey
- Extend WP_User_Query or WP_User to return all custom fields?
- User biographical information erased on login
- Fetch User Meta Data
- If logged in user meta is
- User management missing after migration to new host
- WP Cron: Save third party data as user meta
- Reordering fields in registration form via custom plugin
- Display and Allow users to edit their own profiles
- Validate user meta and redirect
- Let admin users edit member profiles from front end
- Does WordPress Need BuddyPress to Handle Large Amounts of Users?
- Strip Twitter Username from Profile Field with URL and Save to New Profile Field
- Store subscription details for users in WordPress
- Custom user meta values in shortcode
- Update another users meta
- How to add custom detail page for a Subscriber at Admin Panel
- Import users and custom user meta from csv
- Export user data from Squirrly’s Starbox plugin?