Last active
May 5, 2025 13:35
-
-
Save j2machado/c948ca0b2f08157e1fb92b31141f46bb to your computer and use it in GitHub Desktop.
Show the Login Form first in the LearnDash Registration form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Show the Login Form first on the Registration page. | |
*/ | |
add_action( 'wp_footer', function () { | |
// Get the LearnDash registration page ID. | |
$ld_registration_page_id = learndash_registration_page_get_id(); | |
// Exit if user is already logged in or not on the registration page. | |
if ( is_user_logged_in() || get_the_ID() !== $ld_registration_page_id ) { | |
return; | |
} | |
// Enqueue jQuery only if it's not already enqueued. | |
if ( ! wp_script_is( 'jquery', 'enqueued' ) ) { | |
wp_enqueue_script( 'jquery' ); | |
} | |
?> | |
<script> | |
( function($) { | |
// Check if jQuery is defined. | |
if ( typeof $ === 'undefined' ) { | |
console.error( 'jQuery is not loaded' ); | |
return; | |
} | |
$( document ).ready( function() { | |
$( '#learndash_registerform, .registration-login' ).hide(); | |
$( '.registration-login-form, .show-register-form, .show-password-reset-link' ).show(); | |
}); | |
})( jQuery ); | |
</script> | |
<?php | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment