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 awakekat/9c3507d1c6bafc4d2a70 to your computer and use it in GitHub Desktop.
Save awakekat/9c3507d1c6bafc4d2a70 to your computer and use it in GitHub Desktop.
// Creates Login Shortcode
// Shortcode Usage: [loginform redirect="http://my-redirect-url.com"]
function pippin_login_form_shortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
'redirect' => ''
), $atts ) );
if (!is_user_logged_in()) {
if($redirect) {
$redirect_url = $redirect;
} else {
$redirect_url = get_permalink();
}
$form = wp_login_form(array('echo' => false, 'redirect' => $redirect_url ));
}
return $form;
}
add_shortcode('loginform', 'pippin_login_form_shortcode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment