1
votes

I have designed a plugin and in a part of its functionalities I'm trying to save some data to a custom table in MySQL based on the ID of new registered user in Wordpress registration form. I used user_register hook as follow:

function my_func($user_id){

    // some DB Query code based on $user_id
}

add_action('user_register', 'my_func', 10, 1);

I already tried solution in Wordpress user_register hook not executing? and used profile_update hook as described there but it couldn't help. I also tried changing priority value and removed it but the problem still exists.

The only thing I want is to have access to ID of the new registered user in registration form. I appreciate if someone could help me.

1

1 Answers

1
votes

I finally could find the solution. Actually in the body of myfunc function in the question I was trying to output the $user_id using javascript alert and for some reason that script doesn't run at that point but my query runs successfully and the way that I used the user_register hook is correct.

I just want to share it in case anybody encountered such a problem.

Thanks.