WordPress login form tags: WP_ login_ form

In fact, if we need to output a login form from the WordPress foreground, we only need the WordPress template tags WP_ login_ That’s enough.

wp_login_form( string|array $args = '' )

Function parameters$args

Array or string value

wp_ login_ The default value of the $args parameter of the form() function is as follows:

$args = array(
	'echo'           => true,
	'remember'       => true,
	'redirect'       => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
	'form_id'        => 'loginform',
	'id_username'    => 'user_login',
	'id_password'    => 'user_pass',
	'id_remember'    => 'rememberme',
	'id_submit'      => 'wp-submit',
	'label_username' => __( 'Username' ),
	'label_password' => __( 'Password' ),
	'label_remember' => __( 'Remember Me' ),
	'label_log_in'   => __( 'Log In' ),
	'value_username' => '',
	'value_remember' => false

wp_ login_ The following values are available for the $args parameter of the form() function:


Boolean value, default value: true

Whether to output the result. If it is false, only the result will be returned without output.


String value, the default is the current page URL

Which page the user will return to after logging in will return to the current page by default, which is usually the best choice.

form_ id

String value, default value: loginform

The value of the login form ID property


Boolean value, default value: true

Do you want to display the remember my login information option

value_ username

String value, null by default

The default value of the log text box is the default value of the user name input box.

value_ remember

Boolean, default: false

This is more practical. Set whether the “remember my login information” option is selected by default and not selected by default.

Examples of function usage

Set the default value of user name input box as “please enter user name…”, and check “remember my login information” by default

	$args = array(
		'value_remember' => true,
		'value_username' => 'enter one user name...'

The following code outputs the same result:

<?php wp_login_form('value_remember=1&value_username=enter one user name...'); ?>

Extended reading

wp_ login_ The form() function is located in: WP includes / general- template.php

Related tags:

  • is_ user_ logged_ in()
  • wp_ loginout()
  • wp_ logout()
  • wp_ register()
  • wp_ login_ url()
  • wp_ logout_ url()
  • wp_ lostpassword_ url()
  • wp_ registration_ url()
Related Article
WordPress comment date tag: comment_date

WordPress template tags comment_ Date is used to output the date of a comment, usually in a custom comment template. Read more

WordPress comment summary tag: comment_excerpt

WordPress template tags comment_ Excerpt is used to output the summary of comments. The default output is 20 characters. It Read more

WordPress comment time tag: comment_time

WordPress template tags comment_ Time is used to output the publishing time of the current comment, which is the same Read more

WordPress RSS format comment author name tag: comment_author_rss

WordPress template tags comment_ author_ RSS is used to output the comment author name in RSS format, which has no Read more

Leave a Reply

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

To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image