wp_login
hook provides access to two parameters: $user->user_login
(string) and $user
( WP_User ). To pass them into your function you will need to add a priority (default is 10) and request 2 arguments from the add_action() call:
function login_cookie($user_login, $user) {
global $wpdb;
var_dump($user); // get WP_User object
//Get current user ID
$id = $user->ID;
.....
}
add_action( 'wp_login', 'login_cookie', 10, 2 );
Related Posts:
- Can’t log in: “ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.”
- Login page ERROR: Cookies are blocked due to unexpected output
- Removing username from the ‘wordpress_logged_in’ cookie
- Getting “Cookies are blocked or not supported by your browser” on login page
- Cookie settings for session across WPML subdomains using custom AJAX login
- Login redirect_to loop with reauth=1, cookie expiry set to 1 year in past
- Login with cookie but without using WordPress code
- Get wordpress stored cookies for custom login
- How to get login data (session) outside WordPress?
- Login cookie across multiple domains on network w/ mapping
- Can’t login after URL change
- How to set different cookies for logged in admin users and logged in non admin users?
- 2 wordpress blogs with 1 users table and 1 login
- Logins through alias
- v5.6.2 User cannot stay logged in – wordpress_test cookie placed but not auth cookies
- Removing wordpress cookie from non-wordpress site
- Getting a person’s username from a wordpress cookie
- One time login on 2 different WordPress sites
- How to force “remember me” users to login again?
- Multiple issues with Ajax login function due to browsers and cookies
- Sharing a logged in session with a custom subdmain site?
- Get WordPress logged in username from root domain when WP is installed in a subfolder
- wp-cron event doesn’t run when custom login API is enabled
- Extend Cookie with auth_cookie_expiration not working
- Custom login method appears to ignore auth_cookie_expiration
- Why deleting/removing cookies in WordPress does not log me out from admin?
- Cookies error during first time login attempt
- Opening protected page with cookie?
- WordPress Cookies – wp_set_auth_cookie
- Why doesn’t the “Remember Me” checkbox work for me on a live website? Only works on a local server environment
- Share login status across subdomains without network
- How to remove without touching the pluggable.php the wordpress_logged_in cookie to show the username on login?
- Increase of failed login attempts, brute force attacks? [closed]
- How to prefill WordPress registration with social details
- Redirect user using the ‘wp_login_failed’ action hook if the error is ’empty_username’ or ’empty_password’
- wp_signon() does not authenticate user guidance needed
- How to pass users back and forth using session data?
- Avoid to load default WP styles in login screen
- Integrate recaptcha and wp_signon – what is needed?
- Programmatically log in a wordpress user
- Send reset password link to user from custom lost password form
- how to update current logged user username
- Custom Reset Password & Forgot Password Front End Forms
- Admin user getting message ‘You need a higher level of permission’
- Remove WordPress Login Animation
- Redirect users to a front end wp login page
- Deny a user role to log in after register
- wp_get_referer not working properly after wp_redirect
- Login Button CSS
- Force Users to Login – loop problem
- Is there a better way than checking user is logged in to show or hide adminbar?
- How do I replace “Username” in the WordPress login form?
- Show errors on custom login form [duplicate]
- How to save generated JWT token to cookies on login?
- Change login_message using title
- Changing WP login credential [closed]
- How to change wordpress Log In text
- Can I (and should I) change the login-URL from functions.php?
- WordPress Cant access wp-login.php
- How to remove ‘wordpress…’ text from page titles in tabs
- Using gettext to translate wp-login.php can’t translate `Back to` into other language
- Display first name instead of username
- How can I make a login just like on wordpress.org?
- How to Prevent Brute Force Attack on WordPress
- How can I insert wordpress login screen on a different domain?
- autocomplete=”off” WordPress Login
- Why there is a 302 status when my account and password are right?
- 503 Login WordPress [closed]
- Password recovery URL has error – but not found in code or db
- This webpage has a redirect loop issue
- Create front end member login
- I can’t access my wp-admin dashboard
- Cannot login to WordPress on one device: login refreshes/an error was encountered whilst trying to authenticate
- Make an order of products without login
- Updated : how to make email optional while user registration using default wordpress form
- I can’t log in to `wp-admin` after changing my domain
- My wordpress site crashes when I login!
- End session screen not close automatically after login
- Unable to login with email address as the username – WordPress
- Bypass login page
- Login issue with subdomain installs
- Using WordPress login for a non word-press website
- Using is_user_logged_in() to lock down whole site
- WordPress login is not showing , there is warning?
- WordPress Redirect After logging
- Issue logging in from second computer
- How to Create a login for for subscribers only
- WordPress auto login user after registration only from a specific page
- Custom Field For Login
- User login without username, only password
- Login user after registration programmatically
- wp_lostpassword_url not escaped
- Directory authentication initially succeeded, but no valid profile was found (“get entries” procedure)
- External Authentication
- Login to wordpress with filezilla client [closed]
- I can’t login to wordpress dashboard without SSH
- Member Area Login with Fail Message
- Users cannot log in using popup
- WordPress MU: Cookie error when trying to login on network WP instance
- Login and register by API