Gravity Wiz

Magically enhanced tutorials, snippets and plugins for Gravity Forms!

  • Gravity Perks
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    • Documentation
    • Support
    • Account

Customizing Gravity Forms User Registration Activation Page

Last updated October 17, 2020 | Written by David Smith 304 Comments

  • October 17, 2020: Added support for Gravity Forms User Registration 4.6.

  • September 30, 2020: Migrated snippet to the Snippet Library.

  • January 7, 2020: Fixed noticed generated by use of create_function().

  • October 18th, 2013: Updated custom_maybe_activate_user() function to not rely on rgget() function.

Show All Updates

Stop! There's a better way.

This snippet is available as a plugin with Gravity Perks, a suite of over 33 premium Gravity Forms plugins!

  • View the Plugin
  • Buy Gravity Perks
This article (and associated code) has been updated for Gravity Forms User Registration 3.0. If you have previously implemented this functionality and have upgraded to GFUR 3.0, please update your code with the latest versions below.
Want to customize User Activation emails? We’ve got you covered..

If you’ve checked out the latest beta for the Gravity Forms User Registration add-on, you might have noticed one of the awesome new features is “Pending Activations”. Here’s how they work.

When the user signs up, instead of automatically being registered as a user on your WordPress site, an activation email is sent to the email address they signed up with. The activation email contains an activation link. When the user clicks this link and visits the activation page, they are “activated” and their user account is registered.

One of the first things you’re probably going to want to do with this new feature is customize the activation page. This is the page where users land after clicking the activation link in the activation email. This walk-through aims to demonstrate how this activation page can be completely customized.

This process can be broken down into two simple steps:

  1. Create a custom activate.php template
  2. Override default activate.php template

1. Create a Custom activate.php Template

At the most basic level, all you need to do here is find the activate.php file in the GF User Registration plugin folder and place a copy of this file in your theme folder.

  • Path to GF User Registration activate.php file
    /wp-content/plugins/gravityformsuserregistration/includes/activate.php
  • Sample path to your theme folder
    /wp-content/themes//

The issue with this is that the activate.php template really isn’t easy to customize. There are a lot of nested conditionals and special variables that you probably won’t understand without really digging in.

GW Activate Template

To alleviate some of this burden, I’ve created a special version of the activate.php which you can download and include in your theme which is much simpler to customize. The primary benefit is that it takes 99% of the HTML output that lives in the activate.php template and moves it out to easy-to-edit template parts.

GW Activate Template on GitHub

Just click the “zip” button to download all the template files. Once downloaded, unzip the gfur-activate-template-master.zip file. Inside you will find a gfur-activate-template-master folder. Rename this to “gfur-activate-template” and move this folder into your theme folder.

github-download-zipDownload GW Activate Template Files

The Different Views of Activation

There are several different “views” or “parts” of the activation page.

activate-success
Success
This is the default view that a user will see after clicking the activation link in the activation email. This view is handled by the activate-success.php template part.
activate-error-already-active
Error: Already Active
Occurs when a user attempts to activate an activation key which has already been activated. This view is handled by the activate-error.php template part.
activate-error
Error
If anything goes wrong during the activation (i.e. bad activation key, username already registered, etc), this view will handling displaying the error. This view is handled by the activate-error.php template part.
activate-no-key
No Key
It’s quite unlikely that users will see this view since the activation key is passed in the activation link; however, for the sake of completeness, this view is what the user will see if no activation key is passed in the activation link. This view is handled in the activate-no-key.php template part.

2. Overriding the Default Activation Template

With the template files in place, you’re ready to override the default activate template files to point to your custom files. Doing this is actually pretty simple. Just add this code to your theme’s functions.php file:

/**
* Gravity Forms Custom Activation Template
* http://gravitywiz.com/customizing-gravity-forms-user-registration-activation-page
*/
add_action( 'wp', 'custom_maybe_activate_user', 9 );
function custom_maybe_activate_user() {

	$template_path    = STYLESHEETPATH . '/gfur-activate-template/activate.php';
	$is_activate_page = isset( $_GET['page'] ) && $_GET['page'] === 'gf_activation';
	$is_activate_page = $is_activate_page || isset( $_GET['gfur_activation'] ); // WP 5.5 Compatibility

	if ( ! file_exists( $template_path ) || ! $is_activate_page ) {
		return;
	}

	require_once( $template_path );

	exit();
}

In plain speak, this code says: “Here is a path to the template file I’d like to use for my activation page. If this file exists and we’re on the GF User Registration activation page, go ahead and load my custom activation page file.”

If you’re using the GW Activate Template files and followed the instructions above, you won’t need to change this snippet at all. It’ll just work. Otherwise, you will need to change the $template_path variable to point to the location of your own custom activate.php file.

Is it possible to customize the activation email sent to the user?

Yup! We’ve written a tutorial with step-by-step instructions on how you can customize the user activation email. Check it out.

Anything else?

That’s it for now. Give it a go and let me know how it works out of you. I’m eager for any feedback you have!

Did this resource help you do something awesome with Gravity Forms? Then you'll absolutely love Gravity Perks; a suite of 32+ essential add-ons for Gravity Forms with support you can count on.

  • View All Perks
  • Buy Gravity Perks

Filed Under: Tutorials

Comments

  1. RB says

    November 5, 2020 at 2:20 pm

    Thank you – a work in progress, but intelliphense spots this:

    https://pasteboard.co/JyZHOaI.jpg

    Undefined constant ‘file‘

    Reply
    • Ryan Donovan says

      November 5, 2020 at 2:56 pm

      Hello RB, Thank you for that information. When you apply this to your site and run it live, do you get this error? Let us know. ๐Ÿ˜ƒ

  2. henry says

    October 23, 2020 at 12:56 pm

    Why not combine this plugin with GF Better User Activation so that users can use Elementor or WPBakery with the addon?

    Reply
    • Ryan Donovan says

      October 23, 2020 at 1:46 pm

      Hey Henry, this is a great question. We currently are just addons for Gravity Forms so we could not combine the two to make one. The Perk we have within Gravity Wiz is created to solve that issue. As Scott previously mentioned Visual page builders are supported in GF Better User Activation using the [gpbua] shortcode. Is there something that you are looking for that is not resolved within these solutions? Let us know and we would be happy to help!

  3. Henry says

    October 18, 2020 at 2:50 pm

    Great thanks for this. I installed and seems to work. But I am using Elementor for all my page themes. How can I put what you did into my normal Elementor page template?

    Reply
    • Scott Buchmann says

      October 19, 2020 at 9:52 am

      Hi Henry,

      Visual page builders are supported in GF Better User Activation using the [gpbua] shortcode.

  4. Peter Netz Lassen says

    October 6, 2020 at 4:51 am

    Hi Maybe this is more a fuature request?

    I HAVE to manually activate a new user. So I would ask if this auto activation could look “human” maybe with more than one “Office hour” random minutes activation delay?

    Hope that can be done?

    Peter

    Reply
    • Samuel Bassah says

      October 6, 2020 at 8:22 am

      Hi Peter,

      I’m not sure I understand your request very well, but you could send Users an activation link to activate their account. Also, Gravity Forms User Registration Add-on is what actually handles the user activations, so you may want to contact Gravity Forms Support with the Feature Request.

      Best,

    • Peter says

      October 6, 2020 at 9:20 am

      Hi Samuel, Thx – I sent it to Gravity … Lets see if they can make it.

      Best,

  5. Mike Rosekrans says

    September 17, 2020 at 7:30 pm

    It seems to work, but all styles are missing. Did I do something wrong?

    Reply
    • Samuel Bassah says

      September 18, 2020 at 7:52 am

      Hi Mike,

      Do you already have the snippet inserted inside your theme’s function.php file? Please note that template files are supposed to use the theme’s styles and it’s just a starting point for you in case you want to do advanced customization.

      In case the issue you’re experiencing is with the Theme’s styles not displaying at all, then we’ll have to take a closer look to determine what may be wrong. If you have a Gravity Perks License, you can send us a message via our support form so we can dig into this.

      Best,

  6. PAUL CABALLERO says

    September 15, 2020 at 11:55 am

    Hi, thanks for all the assistance. I have another question. Some people receive an error message when they want to activate their account: “activation was not successful due to following error: invalid activation key”

    Can I activate it manually? Or what should they do to correct that error and activate their account?

    Reply
    • Samuel Bassah says

      September 15, 2020 at 1:17 pm

      Hi Paul,

      There have been known issues where using BuddyPress conflicts with Better User Activation which generates a similar error. In case you have BuddyPress, unset the “Activation” page in BuddyPress Settings. Also, you can manually activate a user account within the Form entry page.

      Best,

  7. paul says

    September 14, 2020 at 12:20 pm

    Hi, Is it possible that users do not have to activate their account with the link? Is there an option for them to directly use their account once they have uploaded their username and password?

    Reply
    • Scott Buchmann says

      September 14, 2020 at 2:39 pm

      Hi Paul,

      Sure. Don’t enable user activation in the User Registration feed, and then use Auto Login to automatically log them in after registering.

  8. Joachim says

    September 7, 2020 at 12:35 pm

    FYI: The latest update of the User Registration Add-on uses a new activation link โ€“ domain.ext/?gfur_activation=XXX โ€“ as explained in the change log: “Updated the activation page query string to use the “gfur_activation” parameter instead of “page” to fix an issue with WordPress 5.5 where a 404 not found error occurs. Existing activation links will automatically redirect to the new page.”

    As a result, the code above no longer works, altdough it’s rather straightforward how to change it to work with the new queryvar.

    Reply
    • Ryan Donovan says

      September 8, 2020 at 1:18 pm

      Hello Joachim, Thank you for bringing this up. I will forward this to my team and we will update this with the necessary steps moving forward. Have a wonderful day.

    • Jyoti says

      November 24, 2020 at 5:47 am

      I am also facing same issue, please suggest a solution for the same.

    • Samuel Bassah says

      November 24, 2020 at 6:45 am

      Hi Jyoti,

      This issue has been resolved in the updated version of the snippet. You can get the updated version of the snippet from the Snippet Library.

      Best,

  9. Carla says

    September 2, 2020 at 6:28 am

    Hello – this is a great tutorial – thank you!

    I am having an issue whereby the new template (wheter extended or simple) does not use the theme css of the rest of the site. That is, the header and footer and body have no styling.

    Any tips on why that may be happening?

    This is my site:

    https://course.sustainabilityteachers.org/

    Reply
    • Ryan Donovan says

      September 2, 2020 at 11:20 am

      Hello Carla, This is a bit of a strange one. I have attempted to test your page but cannot recreate this issue as I see the same header, footer, and body with the correct CSS. You will notice that I have gone through the registration process as well. Is their something specific I should be doing to recreate this issue or is it possibly a cache issue? Let us know.๐Ÿ˜ƒ

« Older Comments

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Categories

  • How To (64)
  • News (21)
  • Plugins (14)
  • Releases (7)
  • Resource (3)
  • Snippets (58)
  • Tutorials (57)
  • Updates (104)

Recent Posts

  • How to Send a Follow-Up and Pre-Fill Information
  • How to Update Posts with Gravity Forms
  • Gravity Wiz Weekly #104
  • The Complete Guide to Using Gravity Forms With Zapier
  • Gravity Wiz Weekly #103

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2021 ยท Powered by WordPress ยท Gravity Wiz LLC

  • Support
  • Affiliates
  • About
  • Sitemap
  • Gravity Perks
    โ–ผ
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    โ–ผ
    • Documentation
    • Support
    • Account