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
- Email user when password is reset by admin
- How to work around “that email address has already been used” error?
- How to hide “Filter user list” from “All Users” screen
- How to create a template for a custom URI associated with the user
- How to manually activate user in dashboard only by admin
- How to check user role without using current_user_can()
- Pre-populate Username Field
- Where to Store Custom User Fields
- Redirect after User Activation [closed]
- How to keep track of user logins?
- Mass delete spam accounts
- Get all commenters on a post
- WP_User->add_role producing unexpected results
- Changing default Buddypress avatar affects all site avatars (because gravatar)
- Best way to have an per-user customized private section
- How to query users who have empty first_name?
- Post as someone else
- How to make user accept license agreement before download
- Does wp_delete_user() remove all user content?
- wp_login_form() passing user ID into URL on redirect?
- Users: List A to Z, for Users
- WPML Default Language User Meta [closed]
- Search Users base on meta_value & meta_key
- How to stop redirect if user is already on correct page (Using Case Switch)
- How to activate the user search
- How change user type from contributor to author
- How to allow registered users to submit the form only 5 times per day?
- Preventing user enumeration: which logic is better?
- How can I do a url redirect to include a wordpress username?
- Allow Users to Modify Some Values of Assigned WordPress Pods [closed]
- Custom registration and pending approval
- Let logged-in users use radio buttons (yes and no) to exclude their author profile from the user listing
- Make new users automatically approved
- How would I restrict certain user levels from editing categories
- How can I set wp_dropdown_users so that it shows only authors?
- Restricting wordpress login sessions for a web app
- Use WP cookie to authentificate user on an external app
- Find count of WordPress users by role and search string for user name
- Users activity history
- Designing a member area on my site
- Link to Authors blog posts
- Redirect based on log-in status per JavaScript
- Create users from frontend without password
- How to get user contact info
- WordPress – Security Question at Login from User’s Meta Data
- get Discussion setting in wordpress
- Remove My Account Menu items in Woocommerce based on user roles