Last active
July 11, 2016 08:05
-
-
Save joeydenbraven/605e914f17440eff56b97cf88689e1c9 to your computer and use it in GitHub Desktop.
Creates a Wordpress login shortcode, so you can create your own login page!
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
// add this to your functions file | |
add_shortcode('shortcode_name_here', 'my_login_form_shortcode'); | |
function my_login_form_shortcode( $attr ) { | |
if ( is_user_logged_in() ) | |
return ''; | |
/* Set up some defaults. */ | |
$defaults = array( | |
'label_username' => 'Username', | |
'label_password' => 'Password' | |
); | |
/* 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 ); | |
} | |
// use this in your template | |
echo do_shortcode('[shortcode_name_here label_username="Gebruikersnaam" label_password="Wachtwoord"]'); | |
// use this in your wordpress editor | |
[shortcode_name_here label_username="Gebruikersnaam" label_password="Wachtwoord"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment