Replace the LearnDash Registration Popup with a Custom Form

Affiliate Disclosure: We may be compensated if you use our links to make a purchase. We are extremely selective in who we partner with & only recommend products we believe in. Our affiliate relationships do not influence our recommendations.

Are you using the LearnDash login & registration modal popup, but want to replace the form with one of your own? Maybe a Gravity Form that utilizes user registration, or a custom form you built with WPForms.

LearnDash provides a way to use the registration popup and just replace the form that shows up within it. This article will show you how to do just that.

The following example will use a Gravity Form, but you can use the same method—and nearly the same code—for any other form that can be inserted via a shortcode.

Create Your Form

You obviously need to create a form first. We aren’t going into detail on how to do this. Please consult the documentation for whatever form plugin you’re using.

Recommended ProductKinsta hosting site speed boost

IMPORTANT
Be sure it’s set up to create a new user account on your WordPress site. You can optionally add a payment field if you’d like to offer premium registrations.

Custom Code Snippets

My preferred way to make changes like we’re about to make is with the Code Snippets plugin. You could also add this code to the functions.php file of your child theme (if you’re using one), but I find Code Snippets to be easier to manage and less likely to bring your site down if you make a mistake.

  1. Install & activate “Code Snippets” from your WordPress plugins page
  2. Navigate to Snippets > Add New in the left sidebar
  3. Give your snippet a name. Something like “LearnDash – Custom Registration Form”
  4. Paste the code snippet into the Code area
  5. Choose the Only run on site front-end option
  6. Click the Save Changes and Activate button

Replace the LearnDash Form with a Custom Form

Here’s the code snippet that will replace the LearnDash registration form with a custom form of your own (Gravity Forms, WPForms, Formidable Forms, etc.).

Be sure to change the form ID in your code to match the form you set up for registration. In this example, 123.

add_action( 'learndash_register_modal_register_form_override', 'ldx_custom_reg_form' );

function ldx_custom_reg_form() {
	echo apply_shortcodes( '[gravityform id="123" title="false" description="false"]' );
}

If you’re not using Gravity Forms, simply look up the shortcode syntax for your form plugin, and use that instead. The only thing you need to change is the shortcode itself (the stuff inside the [ and ] brackets).

Previous

Limit the Width of the LearnDash Login Modal

Next

How to Use Custom Fonts for H5P in WordPress

10 Comments

  1. Alya

    Hello,

    From the popup modal, is there a way to link the ‘register an account’ button to a url page instead of clicking it and popped out the username & email field? I want to remove the fields, and just want to direct them to a custom registration page that I have made.

    This tutorial here https://onexlab-io.medium.com/learndash-custom-registration-form-a93f0b1b66d8 requires to edit the core file. So it will be overwritten once I update LearnDash.

    Is there a code that I can edit through my child theme?

    Any help is much appreciated.

    • You can use the code above to replace the username & email fields and use a form of your own. This will do exactly the same thing as that other article you linked, but it will not affect any core files. Using the Code Snippets plugin is essentially the same thing as using a child theme.

      If you want to redirect the “register an account” button to a completely different page, you’ll need to ask LearnDash if there’s a hook for that. First, I would search developers.learndash.com. If you can’t find anything there, you can reach out to LearnDash support.

    • I have written an article on that topic, it must be helpful. Just a quick snippet is all you need. https://awais.me/replace-learndash-popup-url-with-custom-link/

    • Thanks for sharing, Awais!

  2. anonymous

    Hi Dave,

    Thank you for this great tip. However, I followed your steps one-by-one but it doesn’t work!
    I am not using the Gravity, or WPForms. I have the “User Registration” and the “RegistrationMagic” forms. I tested both of them by replacing what inside the [] brackets with their shortcodes but with no positive result 🙁

    Any help plz?

    • It’s hard to say without looking at your site. What is being displayed on the login popup? Can you post a link to your site?

  3. Hi, your tutorial works great, I just have one issue. I changed the default registration form with registration form for uncanny codes, but now when I hit register, email verification or password requirements doesn’t work. Instead of form showing error if email already exists it just redirects back to page.

    If I use exact form on standalone page everything works.

    Any suggestions what could be wrong?

    • My only thought is that the Uncanny Codes form uses some different parameters than a standard registration form, and those are tripping up the Submit button of the LearnDash modal. I don’t use Uncanny Codes and don’t have time to set up a demo to test it so I’m sorry but I can’t be of much help.

      I’d reach out to Uncanny Owl support if you haven’t already. They might have a better answer for you.

  4. Leon Harris

    Hi Dave – thanks for the code – got it all working apart from one issue…

    when the registration form has errors in it, the modal window closes anyway preventing the user from seeing the error messages (and thinking that it’s not working).

    if there a way of preventing modal window close until the form has been validated? thanks for any help!

    • I definitely see how that provides a poor user experience. I would want to find a way to show the errors as well.

      Unfortunately, I don’t have a quick answer for you, and I don’t have time to dig into LearnDash’s modal code to be able to provide you with a solution. Sorry.

      There’s a guy named Wallace Miller in the LearnDash Facebook group who might be able to provide you with a solution though. Considering posting in there.

Leave a Reply

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