{"id":1423,"date":"2018-02-26T22:33:11","date_gmt":"2018-02-27T04:33:11","guid":{"rendered":"https:\/\/wpcodeus.com\/?p=1423"},"modified":"2025-07-30T11:04:27","modified_gmt":"2025-07-30T16:04:27","slug":"gravity-forms-automatically-login-user","status":"publish","type":"post","link":"https:\/\/wpcodeus.com\/gravity-forms-automatically-login-user\/","title":{"rendered":"Tutorial: Gravity Forms Automatically Login User After Registration"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"1423\" class=\"elementor elementor-1423\" data-elementor-post-type=\"post\">\n\t\t\t\t<div class=\"elementor-element elementor-element-271f408 e-flex e-con-boxed parallax_section_no qode_elementor_container_no e-con e-parent\" data-id=\"271f408\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-d113561 elementor-widget elementor-widget-text-editor\" data-id=\"d113561\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>In this tutorial we are going to show you how to make Gravity Forms Automatically login user after they register for an account. The default behavior in WordPress after registration is to require the user to login with the account information that they just created. This login requirement can be an annoying and extra step for the user and isn\u2019t necessary.<\/p><p>In order for this to work it\u00a0<strong>requires\u00a0<\/strong>the\u00a0<a href=\"https:\/\/www.gravityforms.com\/add-ons\/user-registration\/\" target=\"_blank\" rel=\"noopener nofollow\">User Registration Add-On\u00a0<\/a>\u00a0for Gravity Forms. Assuming this add-on is installed and activated, go ahead and navigate to your current themes functions.php file where we will be adding our code.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-50f81f7 e-flex e-con-boxed parallax_section_no qode_elementor_container_no e-con e-parent\" data-id=\"50f81f7\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-6d49480 elementor-widget elementor-widget-heading\" data-id=\"6d49480\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Gravity Forms Automatically login user after registration<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1d62960 elementor-widget elementor-widget-text-editor\" data-id=\"1d62960\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>In order to get this function to work all you have to do is add the following code snippet to your current theme\u2019s functions.php file. As usually, if you don\u2019t have a child theme installed on your website we highly recommend you do that and paste it in the child themes functions.php. If you don\u2019t have a child theme and would like to create one, here is a tutorial\u00a0<a href=\"https:\/\/optimizerwp.com\/wordpress-child-theme\/\" rel=\"nofollow noopener\">how to create a WordPress child theme<\/a>.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-ad3542d e-flex e-con-boxed parallax_section_no qode_elementor_container_no e-con e-parent\" data-id=\"ad3542d\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-1522509 elementor-widget elementor-widget-code-highlight\" data-id=\"1522509\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-php line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-php\">\n\t\t\t\t\t<xmp>add_action( 'gform_user_registered', 'wpc_gravity_registration_autologin',  10, 4 );\n\/**\n * Auto login after registration.\n *\/\nfunction wpc_gravity_registration_autologin( $user_id, $user_config, $entry, $password ) {\n\t$user = get_userdata( $user_id );\n\t$user_login = $user->user_login;\n\t$user_password = $password;\n       $user->set_role(get_option('default_role', 'subscriber'));\n\n    wp_signon( array(\n\t\t'user_login' => $user_login,\n\t\t'user_password' =>  $user_password,\n\t\t'remember' => false\n\n    ) );\n}<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-e25680e e-flex e-con-boxed parallax_section_no qode_elementor_container_no e-con e-parent\" data-id=\"e25680e\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-3f5dca2 elementor-widget elementor-widget-text-editor\" data-id=\"3f5dca2\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>That\u2019s all there is to it! You just made\u00a0Gravity Forms Automatically login user after they have filled out your registration form using the\u00a0<a href=\"https:\/\/www.gravityforms.com\/add-ons\/user-registration\/\" target=\"_blank\" rel=\"noopener nofollow\">User Registration Add-On.\u00a0<\/a><\/p><p>We have plenty of other great Gravity Forms WordPress tutorials that you can check out here:\u00a0<a href=\"https:\/\/wpcodeus.com\/tag\/gravity-forms\/\" target=\"_blank\" rel=\"noopener\">Gravity Forms WordPress Tutorials<\/a>. One of our recent tutorials we show you how to\u00a0<a href=\"https:\/\/wpcodeus.com\/wordpress-tutorial-create-unique-id-gravity-forms-entries\/\">Create a Unique ID for Gravity Forms Entries<\/a>.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-7736d04 e-flex e-con-boxed parallax_section_no qode_elementor_container_no e-con e-parent\" data-id=\"7736d04\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-65b464f elementor-widget elementor-widget-heading\" data-id=\"65b464f\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Redirect User After Login<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3dd9ac7 elementor-widget elementor-widget-text-editor\" data-id=\"3dd9ac7\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>As an extra bonus we thought we would include this little hint as well just in case you\u2019re new to Gravity Forms. Now that you have Gravity Forms Automatically login users after registration, what if you want to have them redirect to a specific page afterwards?<\/p><p>To configure the URL to which the user should be redirected to, you will simply need to go into the\u00a0 Forms\u00a0<strong>Settings<\/strong>\u00a0and under\u00a0<strong>Confirmations<\/strong>\u00a0and\u00a0<strong>Confirmations Type<\/strong>\u00a0simply click Page and choose the desired page.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6cae103 elementor-widget elementor-widget-image\" data-id=\"6cae103\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"372\" src=\"https:\/\/wpcodeus.com\/wp-content\/uploads\/2018\/02\/redirect-page-1024x372.jpg\" class=\"attachment-large size-large wp-image-1424\" alt=\"Gravity Forms Redirect After Login\" srcset=\"https:\/\/wpcodeus.com\/wp-content\/uploads\/2018\/02\/redirect-page-1024x372.jpg 1024w, https:\/\/wpcodeus.com\/wp-content\/uploads\/2018\/02\/redirect-page-300x109.jpg 300w, https:\/\/wpcodeus.com\/wp-content\/uploads\/2018\/02\/redirect-page-768x279.jpg 768w, https:\/\/wpcodeus.com\/wp-content\/uploads\/2018\/02\/redirect-page-700x254.jpg 700w, https:\/\/wpcodeus.com\/wp-content\/uploads\/2018\/02\/redirect-page.jpg 1185w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Gravity Forms is one of the best Wordpress form plugins out there. If you&#8217;re using the Gravity Form User Registration addon in this Wordpress tutorial we are going to show you how to automatically login users after registration. Click to get started!<\/p>\n","protected":false},"author":1,"featured_media":1426,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[249,68],"tags":[71,73,69],"class_list":["post-1423","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress-tutorials","category-code-snippets","tag-functions-php","tag-gravity-forms","tag-wordpress"],"acf":[],"_links":{"self":[{"href":"https:\/\/wpcodeus.com\/wp-json\/wp\/v2\/posts\/1423","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpcodeus.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpcodeus.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpcodeus.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wpcodeus.com\/wp-json\/wp\/v2\/comments?post=1423"}],"version-history":[{"count":0,"href":"https:\/\/wpcodeus.com\/wp-json\/wp\/v2\/posts\/1423\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpcodeus.com\/wp-json\/wp\/v2\/media\/1426"}],"wp:attachment":[{"href":"https:\/\/wpcodeus.com\/wp-json\/wp\/v2\/media?parent=1423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpcodeus.com\/wp-json\/wp\/v2\/categories?post=1423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpcodeus.com\/wp-json\/wp\/v2\/tags?post=1423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}