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 hook in to automatically sign-in the user after registration. (using a GravityForms registration form).

None of the hooks seem to be working. I've tried: gform_user_registered, user_register, a filtered 'update_user_metadata'....

Why would this not kill the script after a registration happens?

add_action("user_register", "my_auto_login");
function my_auto_login($user_id) {

Login after registration seems like it should not be that complicated.

share|improve this question
Isn't there a support forum at the gravity forms site? It's a commercial plugin... – kaiser May 23 '11 at 23:26
up vote 0 down vote accepted

Use the Gravity forms gform_user_registered hook. It fires after the registration and will return the $user_id.

function my_auto_login( $user_id ) {
wp_set_auth_cookie( $user_id, false, is_ssl() );
wp_redirect( admin_url( 'profile.php' ) );

add_action( 'gform_user_registered', 'my_auto_login' );
share|improve this answer
Perhaps the order of the action and function matter? It seems that they are reversed in a lot of examples. Either way, I've never seen wp_set_auth_cookie() used like that to make this work. Thanks A TON Chris ! – J_B May 24 '11 at 0:25
@J_B I guess it worked pretty cool. There is also wp_set_current_user($user_id); but I guess it's not needed here. – Chris_O May 24 '11 at 0:47
yes, it did work. One attempt of mine was using wp_set_current_user along with a set cookie function.. but your suggestion was the only one that seemed to do anything. I would still like to know why putting die() had no effect.. Thanks again. – J_B May 25 '11 at 7:47

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.