wp_get_current_user then compare the object that’s returned user_login proprety with the specific username you’d like to check against.
<?php
add_action('admin_init', 'wpse74389_check_username');
function wpse74389_check_username()
{
$user = wp_get_current_user();
if($user && isset($user->user_login) && 'username_to_check' == $user->user_login) {
// do stuff
}
}
Related Posts:
- How to programatically change username (user_login)?
- How to restrict access to uploaded files?
- Allowing users to edit only their page and nobody else’s
- Disallowing Users of a Custom Role from Deleting or Adding Administrators?
- Hide Admin Menu for Specific User ID who has administrator Role
- Allowing an email as the username?
- Post list based on the user that is logged in
- Basic auth WordPress REST API dilemma
- Copy a user from one WordPress site to another
- Front end user meta options for users
- How to customize wp_signon()
- Can I create users that have access to *some* other users posts instead of all other users posts?
- Set default page for user account in admin
- Share user table from WP with Drupal
- Log all users out of all locations after 24 hours
- Hide everything on site for visitors except specific page IDs
- Managing Users and Creating Groups [closed]
- show text If special user is logged
- Upgrade Nightmare – No Posts, Permissions Issues and Can’t Create a new post
- How to disable a specific page for a specific user
- Allow user access to Dashboard only!
- Restrict access of admin uploads to certain logged-in users?
- wordpress user roles are not working
- Displaying different in-page content to cliente/admin
- Problem with automatic role change through cron job
- Reset Password policy
- How can I allow an User to publish only 5 posts per month?
- Where are $current_user->allcaps set?
- How do you manage your pages or functions that require logged-in users?
- Allow admins to login as other users
- Can I Create a Second Admin Level User Role?
- Delete a user from frontend
- Unique password to access a section site
- One Click Access To Users Account In WordPress?
- Using my own user table
- WordPress user role with create user capability?
- Update user role for expired membership
- How to use url formatter with integer
- Custom User Role: Can Edit Own Page, Cannot Create New
- WordPress install checking permissions of user id 0
- throttle/limit a logged in user’s http requests to specific page on a per day basis
- Allowing users to edit only their page and nobody else’s
- How to bulk change user role to “No role for this site”
- Restrict Access to the User Profile
- post acces for guests / unregistered users only
- Username has been exposed
- view and update form only for registered users
- Control Category of each user can post
- Limit user access to installing/configuring a plugin?
- determine active user browser at the same time
- MySQL query to list users who never signed in
- Wordpres password as plain text in email
- WordPress password as plain text in email
- (How) does WordPress protect direct access of user data?
- How to remove/limit Editor accounts privileges, to prevent them from deleting media and pages created by Admin
- Add Custom Filter to Admin User list
- WordPress SQL Issue not returning correct reselts
- List Users alphabetically with heading
- How to default/force the user’s display_name to their nickname?
- Restrict access to non-wordpress section of site with user roles?
- how to remove email field from default user registration form on wordpress
- Add custom user meta data
- Does it matter if the very first user, usually Admin, does not have a user ID of 1?
- How to set default’ => $current_user->user_login
- Groups and subgroups for permission
- How to add an attribute to a user?
- Can i use two different user tables for on WP install?
- how redirect users to custom login page when “login to reply” is clicked? [duplicate]
- Making WordPress available while logged into another website
- Get user ID when action row link is clicked
- Advanced Custom Fields Plugin: how would I get an image src path uploaded from User Profile?
- Whenever I got to my new pages (http://www.cwmags.com/news) it requests login?
- how to delete in phpmyadmin sql – all users with certain condition and all dependencies
- User with same Mail but a different additional info(like domain)
- current_user_can() causing critical error
- How to connect wordpress user with my own APP user?
- Author Error “Sorry, you are not allowed to access this page.”
- How to give guest users “not logged in” a role?
- How to Moderate Edits to User Profiles?
- Front-end uploader logging user out when they attempt to upload image
- Upon running wp_insert_user() WP Keeps Saying user_login is already in the system when it isn’t
- WP users cant reset password
- Limit a user only to wp-cli only use
- WordPress session times out – but doesn’t log out?
- What is the best user experience for user to perform an action using email?
- How to add karma points to users?
- How to do a search based on the user’s location & search term and return proximity-based results?
- Store extra user values permanently
- New User ID not working in custom function with user_register hook
- Registered access area
- Error when send reset password
- How to disable users changing their display_name?
- Are there any hook or filter when adding new user in WordPress?
- Sort users by custom user meta value
- How can I let users open the site for other visitors?
- when does output of get_user_count turns into an array?
- How-To: Get meta data from the users last order in woocommerce
- Allow Html pages for users with specific roles
- Allow users to edit post without logging in
- Redirect Login Based on User Role