This neat little WordPress code tutorial will show you how to easily create a WordPress Login Form Shortcode using theĀ wp_login_form() function that can then be placed inside any post or page of your WordPress blog. You will be required to edit a file during this tutorial we recommend that you use a good quality text editor like PSPad or similar when editing any PHP files.
Copy and Paste the code below into your themes functions.php file.
function devpress_login_form_shortcode() { if ( is_user_logged_in() ) return ''; return wp_login_form( array( 'echo' => false ) ); } function devpress_add_shortcodes() { add_shortcode( 'devpress-login-form', 'devpress_login_form_shortcode' ); } add_action( 'init', 'devpress_add_shortcodes' );
Now to display the login form usuing a shortcode anywhere in your post or page content simply place the shortcode below into the post or pages editor screen where you would like the login form to display.
[devpress-login-form]
You should now have the ability to add a WordPress login form easily to any page or post.
Leave a Reply
You must be logged in to post a comment.