Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chinmayrajyaguru/a83879f4041c8473c680e0ff23aa5e06 to your computer and use it in GitHub Desktop.
Save chinmayrajyaguru/a83879f4041c8473c680e0ff23aa5e06 to your computer and use it in GitHub Desktop.
Create Custom WordPress login form using Shortcode
// 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