Forked from Njengah/create_wordpress_login_form_shortcode.php
Last active
May 21, 2021 10:04
-
-
Save chinmayrajyaguru/a83879f4041c8473c680e0ff23aa5e06 to your computer and use it in GitHub Desktop.
Create Custom WordPress login form using Shortcode
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
// 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 [jay-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