WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to get user ID on registration and automatically add that ID to my custom table. I am using wp-members plugin for registration.

So is it possible to get user ID on the fly while registering and add that ID to another custom table with WP-Members plugin.

Or I can use custom registration page if require. But need some guideline how to get user ID on the fly during registration.

Anyone please help me..

share|improve this question
up vote 3 down vote accepted

Please take a look at user_register hook

This is fired when a new user is registered and conveniently passes you the user ID of the new user.

function function_name( $user_id )
    /* do what you want to do with ID here */
add_action( 'user_register', 'function_name');
share|improve this answer
Thanks a lot for quick response. Actually I have never done this before so little confuse and need great help from you experts. So in between this I can use $wpdb inser command for inserting user ID to custom table? and how can I know that I should use $user_id and $user_name etc? sorry for dumb question – pixelngrain Aug 30 '12 at 11:11
codex.wordpress.org/Function_Reference/get_userdata will get you all the user details from the ID – Brady Aug 30 '12 at 11:20
My table name is wp_customs and column is customs_id and I tired below code but didn't insert user id when they registers. function get_customs_id($user_id){ global $wpdb; $wpdb->insert( 'wp_customs', array( 'customs_id' => 'value1' ), array( '%d' ) ); } add_filter('user_register', 'get_customs_id'); – pixelngrain Aug 30 '12 at 11:27
Where did you put this code? – Brady Aug 30 '12 at 11:30
In theme function.php ..I want to get user id and need to inset into that table when user get register – pixelngrain Aug 30 '12 at 12:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.