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:
echo
Boolean value, default value: true
Whether to output the result. If it is false, only the result will be returned without output.
redirect
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
remember
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
<?php $args = array( 'value_remember' => true, 'value_username' => 'enter one user name...' ); wp_login_form($args); ?>
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()