Last active
August 29, 2015 14:15
-
-
Save webmasterninjay/f9050e4e913f34c36c77 to your computer and use it in GitHub Desktop.
WP function to create a shortcode to embed login form on page or post
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 | |
// Use the shortcode [jay-login-form] to embed the login form | |
// Create shortcode | |
function jay_add_shortcodes() { | |
add_shortcode( 'jay-login-form', 'jay_login_form_shortcode' ); | |
} | |
// Shortcode callback | |
function jay_login_form_shortcode() { | |
if ( is_user_logged_in() ) | |
return '<p>You are already logged in!</p>'; | |
return wp_login_form( array( 'echo' => false ) ); | |
} | |
// Init the shortcode function | |
add_action( 'init', 'jay_add_shortcodes' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment