Skip to content

How To Add Login Form Into A Page In WordPress

If your WordPress website is a membership WordPress, you might want add login form into a page of your WordPress, instead of using the wp-login.php form. DevPress has a cool snippet which allows you to easily add a login form into your page using a small shortcode.

We will use wp_login_form() & add_shortcode to do this job. First, create shortcode by putting the following snippet to you current theme’s functions.php file:

function trickspanda_login_form_shortcode() {
    if ( is_user_logged_in() )
        return '';

    return wp_login_form( array( 'echo' => false ) );

function trickspanda_add_shortcodes() {
    add_shortcode( 'trickspanda-login-form', 'trickspanda_login_form_shortcode' );

add_action( 'init', 'trickspanda_add_shortcodes' );

Now, just drop the following shortcode to your page to display the login form:


This form will not appear to logged-in users.

Leave a Reply

Your email address will not be published. Required fields are marked *