Login Short Code

Does wordpress have a native “shortcode” I can paste

on a page that will give me a login form? I want to have

a customized login form page not the ugly bland login

page WP makes you sign on with (but don’t want to use

anymore plugins aka: Theme My Login).

Thank you and I am open to solutions and ideas.

  • bamf
    • Design Lord, Child of Thor

    Thanks Mason, this is inline with what I am looking for,

    but I need bit more help getting this going. I tried to simply

    paste the code (see below) in the HTML WYSIWYG editor,

    but does not generate a form.

    Can you provide me some instructions and possibly a

    simple “ready made” “ready to paste” code that mimics

    what the normal /wp-login.php page form does?

    I’m a quicker learner and showing me this would open a

    whole new world of WP for me :slight_smile:

    <?php $args = array(

    ‘echo’ => true,

    ‘redirect’ => site_url( $_SERVER ),

    ‘form_id’ => ‘loginform’,

    ‘label_username’ => __( ‘Username’ ),

    ‘label_password’ => __( ‘Password’ ),

    ‘label_remember’ => __( ‘Remember Me’ ),

    ‘label_log_in’ => __( ‘Log In’ ),

    ‘id_username’ => ‘user_login’,

    ‘id_password’ => ‘user_pass’,

    ‘id_remember’ => ‘rememberme’,

    ‘id_submit’ => ‘wp-submit’,

    ‘remember’ => true,

    ‘value_username’ => NULL,

    ‘value_remember’ => false ); ?>

  • Mason
    • DEV MAN’s Sidekick

    Hiya bamf,

    Normally, you would actually drop the function into your theme template – rather than within a page/post. However, if that’s what you’re wanting to do then a plugin like the one you’ve got there should do the trick.

    You can’t just copy the code from the codex exactly like that. Start with just this:

    <?php wp_login_form(); ?>

    That will give you the basic login form. You can add arguments to it in the array as you have there, but there’s no need to call the form twice.


  • bamf
    • Design Lord, Child of Thor

    Hey Mason,

    I’m close to understanding you and being successful

    with this, but please bare with me and offer a few more

    details on this.

    A) Where do I drop the function in the theme?

    >> What file?

    >> At what line?

    >> Is there a place in the code I should look for?

    B) What exactly do I paste there once the place is


    `<?php $args = array(

    ‘echo’ => true,

    ‘redirect’ => site_url( $_SERVER ),

    ‘form_id’ => ‘loginform’,

    ‘label_username’ => __( ‘Username’ ),

    ‘label_password’ => __( ‘Password’ ),

    ‘label_remember’ => __( ‘Remember Me’ ),

    ‘label_log_in’ => __( ‘Log In’ ),

    ‘id_username’ => ‘user_login’,

    ‘id_password’ => ‘user_pass’,

    ‘id_remember’ => ‘rememberme’,

    ‘id_submit’ => ‘wp-submit’,

    ‘remember’ => true,

    ‘value_username’ => NULL,

    ‘value_remember’ => false ); ?>`

    If my logic is correct… if I paste the above code in the

    right Theme File at the right line and space and then

    paste the code within the PHP EXE shortcode brackets

    [php_exec]<?php wp_login_form(); ?>[/php_exec]

    Then a basic wordpress login form code should appear

    any where the above code is placed (page or post).

    Please reply and confirm :slight_smile:

  • Timothy
    • Chief Pigeon

    Often I find an example good, if you have full membership then download the blogs.mu theme. It has a cool template which can be used when creating a page to actually create a login and register page.

    Looking at the code used there could help you further. :slight_smile:

  • bamf
    • Design Lord, Child of Thor

    Thanks Tim. I do have full membership. I will go check it out.

    It would be super helpful if you could tell me which files and

    even what line of code to look for. I’m just getting my feet

    wet with this, so any extra info saves me countless hours of

    WTF moments :slight_smile:

  • Jonathan
    • The Incredible Code Injector


    Okay, think you suffered enough – laugh.

    Here you go, just drop this into your functions.php file of your theme.

    add_shortcode( 'login-form', 'my_login_form_shortcode' );
    * Displays a login form.
    * @since 0.1.0
    * @uses wp_login_form() Displays the login form.
    function my_login_form_shortcode( $atts, $content = null ) {

    $defaults = array( "redirect" => site_url( $_SERVER['REQUEST_URI'] )

    extract(shortcode_atts($defaults, $atts));
    if (!is_user_logged_in()) {
    $content = wp_login_form( array( 'echo' => false, 'redirect' => $redirect ) );
    return $content;

    The above shortcode keeps all defaults, except the echo (don’t worry about it) and the redirect, which you can choose like this:

    [login-form redirect="http://yoursite.com/somewhere"]

    Hope that helps a bit,


  • Dimitri
    • The Incredible Code Injector


    Thanks to all for this solution. I use It with the “Membership plugin” and it works perfect :wink:

    If i add the function code submitted by @jonathan in my function.php file in my theme, this code will be suppressed if I upgrade the theme.

    Wy not asking the developper of this nice plugin to add this small function directly in the plugin code.

    So, all user could use the shortcode without having to update manually his theme file.


  • Jonathan
    • The Incredible Code Injector


    You don’t have to add the above code to your themes file.

    You can add it to a plugin as well. This is the preferred method when using 3rd party themes.

    There is zero difference between the functions.php and a plugin file :wink: Except you have the choice to disable / enable the plugin file.

    A plugin file looks like this

    Saved as vistonweb_custom_code_snippets.php

    With contents

    Plugin Name: VisitonWeb Custom Code Snippets
    Plugin URL: http://domain.com
    Description: My own personal code snippets that I don't want in my functions file
    Version: 0.0.1
    Author: Dimitri
    Author URI: http://domain.com

    * Drop all your custom code bellow


    add to your plugin folder and activate.



  • cdemz
    • Design Lord, Child of Thor

    Instead of redirecting to a designated page is it possible to go to the page you tried to access?


    1. User tries accessing htytp://mysite.com/page1.

    2. Login page comes up.

    3. User logs in.

    4. User is allowed into Page1.

    The same process even if the page were Page2 or page33.

  • cdemz
    • Design Lord, Child of Thor


    Thanks for the code. I created a plugin from the above code you provided. My only issue is handling bad passwords and resets which bring you to the wp-login.php which is not my login page that uses the shortcode. Is there a way to deal with bad passwords in the shortcodes above?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.