Created
February 25, 2020 17:39
-
-
Save Njengah/fa96025717308df1b979e77e5da3eef2 to your computer and use it in GitHub Desktop.
Create Custom WordPress login form without plugin [ WordPress Login form Shortcode ]
This file contains 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 | |
/** | |
* Code to Create Custom WordPress login form without plugin | |
* @author Joe Njenga | |
* @ gist - | |
*/ | |
// Step 1: Create shortcode | |
function njengah_add_login_shortcode() { | |
add_shortcode( 'jay-login-form', 'njengah_login_form_shortcode' ); | |
} | |
//Step 2: Shortcode callback | |
function njengah_login_form_shortcode() { | |
if (is_user_logged_in()) | |
return '<p>Welcome. You are logged in!</p>'; ?> | |
<div class ="njengah-login-tutorial" > | |
<?php return wp_login_form( | |
array( | |
'echo' => false , | |
'label_username' => __( 'Your Username ' ), | |
'label_password' => __( 'Your Password' ), | |
'label_remember' => __( 'Remember Me' ) | |
) | |
); ?> | |
</div> | |
<?php | |
} | |
// Step 3 : Init the shortcode function | |
add_action( 'init', 'njengah_add_login_shortcode' ); | |
//Step 4 : Use the shortcode [njengah-login-form] to embed the login form on a page or post |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please correct Step 4.
Use the shortcode
[jay-login-form]