Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save j2machado/c948ca0b2f08157e1fb92b31141f46bb to your computer and use it in GitHub Desktop.
Save j2machado/c948ca0b2f08157e1fb92b31141f46bb to your computer and use it in GitHub Desktop.
Show the Login Form first in the LearnDash Registration form
<?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