Created
December 4, 2017 16:54
-
-
Save greenhornet79/ca585eef737eb5e391321486c37a05ef to your computer and use it in GitHub Desktop.
login for shortcode for WordPress
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
| <?php | |
| function 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', 'login_form_shortcode'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment