wp_login is passed two params, but you will need to update your hook to pass them correctly to your function:
function test_mail( $user_login, $user ) {
//$user = wp_get_current_user();
$message .= "CURRENT USER ID: " . $user->ID . "\n";
$to = "[email protected]";
$subject = "Testing mail from login";
$header = "";
$attachments = "";
wp_mail( $to, $subject, $message, $headers, $attachments );
}
add_action('wp_login', 'test_mail', 10, 2);
Read more here: https://developer.wordpress.org/reference/hooks/wp_login/
Related Posts:
- What is the difference between $post_id and get_the_ID()?
- Where to store plugin settings fields
- How can I add columns to the post edit listing to show my custom post data?
- What’s the best method for emptying an option created with the Settings API?
- template_include (overriding default plugin templates via current theme)
- Custom frontend page for plugin without a ‘physical’ page?
- What is nonce and how to use it with Ajax in WordPress? [duplicate]
- Update exisiting site to 3.5 release candidate
- Why does do_action pass a blank string as the first parameter if no $arg is set?
- Using AJAX in a plugin to submit form – REALLY confused
- Plugin Architecture/Design Pattern – is better to use a private Observer/Mediator Pattern for plugin subclasses or WP add_action?
- Post added via wp_insert_post with category doesn’t show in category listing
- How to add more than 1 user role to sub-menu pages
- How to get shortcode to work inside a foreach loop called within a shortcode?
- How to properly use a hook to create template for custom product type in a plugin such as Woocommerce? [closed]
- How to bundle a plugin with a theme, or vice versa
- WordPress Media mime type filter problem 4.0
- Using a front controller in a WordPress plugin, any suggestions?
- How do I determine if a category exists by ID?
- Use theme constants in plugin?
- Self-hosted plugin update problems
- How to avoid creating first submenu page that is same as menu page?
- How can I display an error message after post has been saved?
- What method to use to call a REST API?
- Save image as featured image
- Best choice of options/settings framework for plugin/theme development
- GET parameters interfere with my plugin settings
- What’s the best place to hire a freelance (contract) WordPress developer? [closed]
- Why my database table not created on activation?
- Hide plugin dashboard menu item for specific roles
- How to use relative path with my plugins folders?
- Resizing Images for a Gallery-Plugin?
- Files automatically added
- Adding functions to hooks from within a class
- What filters to call to modify the output of the entire page?
- Is it possible to change a term slug before being saved to the database?
- How To Change Logout Screen Title
- onclick post title in admin area javascript file not working
- How can I edit commit messages in my wp-hosted plugin repo?
- How to integrate CLEditor to comment system?
- Adding dropdown list to tutor lms registration form
- Filtering SelectControl items according the input from another SelectControl in Gutenberg Block (ES5, no JSX)
- How to Bind one post object Type with other postobject Type in Advanced Custom field [closed]
- As a plugin developer, how do I remove a plugin from the global plugin directory? [duplicate]
- Creating custom input fields on the admin side
- How do I access the menus produced by Dashboard > Appearance > Menus
- Determining URIs for plugin pages
- Filter Categories widget to allow custom sorting?
- Can’t get AJAX call working in custom plugin
- How leave selected checkboxes marked after they are selected and saved in the database
- Custom Rest Endpoint: Post/Put/Patch not working
- How to allow only two (or more) users access to a plugin
- Custom avatars in wordpress comments?
- Admin Subpages without Menu entry
- How to create custom dynamic url
- Plugin Development – Get Admin Url (Including cases where wp-admin is not used)
- Any way to update_post_meta with html content? It gets stripped and becomes empty
- How to get the number of pages when paginating comments?
- Add code to template dynamically
- Getting posts by taxonomy
- How Can I Add Code To A Preexisting Function Without Editing it
- can members have multiple registration using the same password?
- Exclude Woocommerce Product Category From Sitemap
- WordPress (pagenow link) in ajaxurl change after i change plugin language
- Creating posts with links from a txt file
- Get API auth_token token to renew weekly
- escape html in jQuery for WordPress
- Detect if requested page is PWA on server side
- Redirection from a specific page for users logged in but not with membership
- use a (Polymer) web component within a plugin (or theme)?
- how to add security questions on wp-registration page and validate it
- Allow user to add the php code in wp_mail()
- Hiding WordPress REST endpoints from public viewing using Basic Authentication
- Plugin setting page – update_option problem
- Customize WordPress Admin Menu
- WordPress Plugin Update Process
- How should I use wpdb class to submit a form in admin dashboard?
- Rewriting URLs with a query string
- Registration form Plugin… Email confirmation
- Forcing ALL plugin Admin menus into a separate menu
- Looking for Hook that is fired after a plugin or wp upgrade is installed/updated
- How to display posts list on my plugin page?
- Can’t add images in wordpress to my page – button isn’t clickable
- WordPress pre-build slider
- Gutenberg and custom blocks messed up pagespeed score. What did I wrong?
- Gutenberg text field validation
- Anyway to prevent admin from seeing other admin’s product?
- Build a dynamic block using the default attributes
- How to display .ptm file in my WP site without JAVA
- Programmatically creating posts based on external JSON feed (asynchronously)
- Bulk post approval and publishing doesn’t work
- Show Admin Menu
- How to replace content of a block in and re-render on change?
- extending a core block doesn’t work inside the editor
- register_activation_hook doesn’t execute without add_action(‘init’,’some-function’)
- Getting similar posts by custom field value
- Does WP REST API cache internally executed (rest_do_request) requests?
- Trouble Importing whatsapp-web.js in a WordPress Plugin Development
- ‘useSate’ error when using React on the frontend in custom block plugin
- Display months on a drop down calendar as TEXT instead of Numbers