Since registration involves a redirect to another page, why not attach your function to init
, which is fired when a WP page is starting to load?
function get_member_ID() {
global $current_user;
get_currentuserinfo();
$ID = $current_user->ID;
// Do stuff with user ID.
}
add_action('init', 'get_member_ID');
Or you could do something when the user logs in:
function get_member_ID_login() {
global $user;
$user->ID;
// Do stuff with user ID.
}
add_action('wp_login', 'get_member_ID_login', 100, 3);
There are some hooks in the registration process, too, I’m just not familiar with them.
Thank you Dcavins,
im not sure i can use the suggestions.well, at least not the second option since i need the function to run right after the registration using information that the user entered.
this is what i am trying to do. the purpose of the plugin is to let members add their location and also to create a search form that let users search members near address entered within a certain radius. There is a already a “location” tab for the user to enter the address and it works fine. Now i am trying to connect the location to the registration form to make it mandatory (if admins choose to). the things is that in order to save the location in the database i need the member’s id.
and so, i am trying to add the location fields into the registration form and make it mandatory and once the user fill up the form it will run the registration process and right after will grad the ID that was created , grad the info from the address fields and run the function i need.
so i guess i need some kind of “after_member_created” hook.