WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/wp login form

Contents

Description

Provides a simple login form for use anywhere within WordPress. By default, it echoes the HTML immediately. Pass array('echo' => false) to return the string instead.

Usage

 <?php wp_login_form$args ); ?> 

Default Usage

 <?php $args = array(
        
'echo'           => true,
        
'redirect'       => site_url$_SERVER['REQUEST_URI'] ), 
        
'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
); ?> 

Parameters

echo
(boolean) (optional) Display the results. Options are:
  • 1 (true)
  • 0 (false)
Default: true
redirect
(string) (optional) URL to redirect to. Must be absolute (as in, http://example.com/mypage/). Recommended: site_url( '/mypage/ ' ).
Default: the current page
form_id
(string) (optional) form_id.
Default: loginform
remember
(boolean) (optional) Whether to remember the values.
  • 1 (true)
  • 0 (false)
Default: true
value_username
(string) (optional) value_username.
Default: NULL
value_remember
(string) (optional)
  • 1 (true)
  • 0 (false)
Default: false

Examples

Default Usage

This simple function displays a login form:

<?php wp_login_form(); ?>

Change Log

Source File

wp_login_form() is located in wp-includes/general-template.php.

Related

Login Tags: is_user_logged_in(), wp_login_form(), wp_loginout(), wp_logout(), wp_register()
Login URLs: wp_login_url(), wp_logout_url(), wp_lostpassword_url(), wp_registration_url()

See also index of Function Reference and index of Template Tags.