Skip to content

Instantly share code, notes, and snippets.

@JudeRosario
Created November 14, 2016 17:23
Show Gist options
  • Select an option

  • Save JudeRosario/a8853b4d7ebf037e13f0203da40ca0ea to your computer and use it in GitHub Desktop.

Select an option

Save JudeRosario/a8853b4d7ebf037e13f0203da40ca0ea to your computer and use it in GitHub Desktop.
add_shortcode('login-form', 'i332i_login_form_shortcode');
function i332i_login_form_shortcode( $attr ) {
if ( is_user_logged_in() )
return '';
/* Set up some defaults. */
$defaults = array(
'label_username' => 'Username',
'label_password' => 'Password',
'redirect' => site_url(),
);
/* Merge the user input arguments with the defaults. */
$attr = shortcode_atts( $defaults, $attr );
/* Set 'echo' to 'false' because we want it to always return instead of print for shortcodes. */
$attr['echo'] = false;
return wp_login_form( $attr );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment