WordPress Tutorials

Add a Login Form to a WordPress Page Without a Plugin

Every WordPress site has a login page at wp-login.php, but it looks plain, it shows the WordPress logo, and it does not match the rest of your site. Visitors who need to log in, such as members, customers, or students, land on a page that feels like a different website. A login form on a normal page keeps them inside your design, with your header and your branding.

This guide shows you how to add login form WordPress page placement without a plugin, using three methods. The Login/out block gives you a no-code form in minutes. The wp_login_form() function gives you full control over redirects, labels, and the remember me checkbox. A third method restyles the default login page itself. All three use core WordPress features, so nothing extra needs installing.

Why Put a Login Form on a Page Instead of wp-login.php?

A page login form improves trust and reduces confusion. A member who clicks Login in your menu expects to stay on your site, not to jump to a bare page with a WordPress logo. When the form sits on a page called Login or My Account, the experience feels professional, and you can add helpful text around it, such as a register link or a password reset link.

A page form also helps with navigation. You can link to it from your menu or footer, and you can control who sees it. A logged in member can see a logout link or a link to their dashboard instead, while a logged out visitor sees the form. That conditional behaviour is hard to get from wp-login.php, which is a single fixed page for everyone.

There is one honest trade off. A page form is a front door, not a replacement for the real login system. WordPress still processes the login itself, and error handling still happens on wp-login.php in some cases. The methods below explain exactly where that line sits.

How Do You Add a Login Form With the Login/out Block?

Method 1 is the fastest route, and it needs no code at all. Create a new page called Login, click the plus icon, search for Login/out, and insert the block. In the block settings on the right, turn on Display login as form. The block now shows username and password fields with a login button, right inside your page content.

Publish the page and add it to your menu if you want visitors to reach it easily. Our guide to add a dropdown menu in WordPress shows how menu links work. Test the form by logging out and logging back in through the page, not through wp-login.php, so you see exactly what a visitor sees.

Now the honest limit. The Login/out block has no error messages of its own. If a visitor types the wrong password, WordPress sends them to wp-login.php to show the error, which breaks the clean on page experience. There is also no remember me checkbox and no redirect setting, so for a site where failed logins are common, Method 2 gives you more control.

The block has one more useful behaviour. When a user is already logged in, it switches to a logout link automatically. That means the same Login page serves both states without any extra work, and a logged in member sees a way out instead of a second form.

How Do You Add a Login Form With wp_login_form()?

Method 2 uses the wp_login_form() function, which prints a complete login form with arguments you control. It needs a little code, but it gives you redirects, a remember me checkbox, and custom labels. You can read the full function reference on developer.wordpress.org if you want every available argument.

The simplest use is a shortcode. Add this snippet to your child theme functions.php file or a Code Snippets snippet, then place the shortcode on your Login page. The shortcode prints the form, and the redirect argument sends users to the My Account page after a successful login.

function vtg_login_form_shortcode() {
    $args = array(
        'redirect'       => home_url( '/my-account/' ),
        'label_username' => 'Username or Email',
        'label_password' => 'Password',
        'label_log_in'   => 'Log In',
        'remember'       => true,
    );
    return wp_login_form( $args );
}
add_shortcode( 'vtg_login_form', 'vtg_login_form_shortcode' );

Place the shortcode on the page by typing [vtg_login_form] in a Shortcode block. Note that the brackets are shown here in encoded form so this post itself never triggers a shortcode, and you should type the normal brackets when you paste it into your own page. The form will show the username and password fields, a remember me checkbox, and a Log In button.

An alternative is a custom page template. Create a template file in your child theme, call wp_login_form() directly inside it, and assign that template to your Login page. The template route suits developers who want custom layout around the form, while the shortcode route suits everyone else. Either way, the form posts to wp-login.php behind the scenes, which is normal and secure.

How Do You Redirect Users After Login?

Redirects decide where a user lands after a successful login. A customer should land on their account page, a student on their course page, and a member on the members area. Sending everyone to the WordPress dashboard is confusing for people who never need the admin area.

The redirect argument in wp_login_form() handles the common case. Set it to the URL of the page you want, using home_url() with the page slug, as in the snippet above. For role based redirects, where admins go to the dashboard and subscribers go to the front end, add a login_redirect filter that checks the role with current_user_can(). Our guide to WordPress user roles explained covers the roles you can test for.

function vtg_login_redirect( $redirect_to, $request, $user ) {
    if ( isset( $user->roles ) && is_array( $user->roles ) ) {
        if ( in_array( 'administrator', $user->roles, true ) ) {
            return admin_url();
        }
        return home_url( '/my-account/' );
    }
    return $redirect_to;
}
add_filter( 'login_redirect', 'vtg_login_redirect', 10, 3 );

Always test redirects with a real subscriber level account, not your admin account, because an admin redirect can mask a broken member redirect. Create a test subscriber, log in through the page form, and confirm you land on the right page. If you land on the dashboard instead, check the redirect slug and confirm no other plugin is overriding it.

How Do You Add a Logout Link?

A login page is only half the job. Logged in users need a clear way out, and a logout link in the menu or on the account page does that. The function wp_logout_url() builds a logout link with a redirect, so users land on a chosen page after logging out.

<a href="<?php echo esc_url( wp_logout_url( home_url() ) ); ?>">Log Out</a>

If you use a menu, add a custom link with the logout URL and label it Log Out. Most themes cannot hide that link from logged out visitors without code, so a simpler route is to put the logout link on the My Account page itself, where only logged in users ever see it. The Login/out block already handles this automatically, which is one reason Method 1 stays attractive for simple sites.

How Do You Restyle the Default Login Page?

Method 3 is different: instead of building a page form, you restyle wp-login.php itself. This suits sites where visitors already land on the default login page from old links. You change the logo, the colors, and the background with the login_enqueue_scripts hook, and you never edit wp-login.php itself, because core updates would overwrite your changes.

Add this snippet to your child theme functions.php file or a Code Snippets snippet. It loads a small stylesheet on the login screen only, so the rest of your site is untouched. Create the stylesheet at the path given in the code, or replace the enqueue with inline CSS. Our full walkthrough in customize the WordPress login page without a plugin covers the logo swap, the background, and the button colors.

function vtg_login_styles() {
    wp_enqueue_style(
        'vtg-login',
        get_stylesheet_directory_uri() . '/login-style.css',
        array(),
        '1.0'
    );
}
add_action( 'login_enqueue_scripts', 'vtg_login_styles' );

You can also change the logo link URL and title with the login_headerurl and login_headertext filters, so the logo points to your homepage instead of wordpress.org. Keep the restyle light: a logo, a background color, and a button color are enough. A heavily rebuilt login screen can confuse users who expect the standard layout.

What Security Basics Should You Follow?

A login form is a security sensitive feature, so treat it with care. Always run your site over HTTPS, because a login form on plain HTTP sends passwords in a readable form. If your host offers a free SSL certificate, enable it before you publish a login page. Our web hosting guide explains what to look for when you choose one.

Limit login attempts, use strong passwords, and enable two factor authentication for admin accounts. A page login form does not change the security rules, but it does make the login more visible, which means bots may find it sooner. Keep WordPress, themes, and plugins updated, and never share admin credentials over email or chat. If a member forgets a password, point them to the lost password link on the form.

  • Use HTTPS on every page.
  • Enable two factor authentication for admin accounts.
  • Limit login attempts to slow brute force attacks.
  • Never email passwords or share admin logins in chat.

Which Method Should You Choose?

Choose the Login/out block if you want a login form today with no code and you can live with the wp-login.php error redirect. Choose wp_login_form() if you need redirects, a remember me checkbox, or custom labels, and you are comfortable adding one snippet. Choose the restyle if your visitors already use wp-login.php and you want that screen branded. Many sites combine Method 2 and Method 3: a page form for members, and a branded wp-login.php as a safety net.

Whichever method you pick, test the full journey before you announce it. Log out, open the login page, enter a wrong password, and note where you land. Then log in correctly and note where you land. Then log out again and confirm the logout link works. If all three paths feel clean, your login setup is ready. A related next step is a contact form for visitors who need help logging in, and our guide to create a WordPress contact form without a plugin covers that with the same no-plugin approach.

Frequently Asked Questions

Can I add a login form to a WordPress page without a plugin?

Yes. Add the core Login/out block to a page and turn on Display login as form, or use the wp_login_form() function inside a shortcode or a custom page template. Both methods use core WordPress features, so no plugin is needed. The form posts securely to the normal WordPress login handler.

Why does a wrong password send users to wp-login.php?

WordPress processes every login through wp-login.php, and the core error messages live on that screen. The Login/out block has no error display of its own, so a failed login redirects there. The wp_login_form() method behaves the same way, because the redirect argument only applies after a successful login.

How do I redirect users to a custom page after login?

Pass a redirect argument to wp_login_form() with the URL you want, such as your My Account page. For different destinations per role, add a login_redirect filter that checks the role with current_user_can(). Test with a real subscriber account, not your admin account.

Is it safe to edit wp-login.php to change the login design?

No, never edit wp-login.php directly, because WordPress updates overwrite core files and your changes will vanish. Use the login_enqueue_scripts hook to load your own stylesheet, and the login_headerurl filter to change the logo link. Keep the changes in a child theme or a Code Snippets snippet.

Last updated: November 2026.

Hostinger - Get 20% OFF

Habib ur Rehman

Hello! I'm the founder of VU Tech Geek. As a BSCS graduate and experienced WordPress professional, I'm passionate about technology and education. My Virtual University journey has given me valuable insights and knowledge, which I love to share with fellow students.… More »

Related Articles

Leave a Reply

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

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker