WordPress set remember login information tags: WP_ signon

WordPress template tags WP_ Signon is used to set remember login information, which is often used in open registered WordPress sites.

wp_signon( array $credentials = array(), boolean $secure_cookie = '' )

Function parameters


Array, empty by default

This array defines the login information to remember. If this parameter is empty, the default value is as follows:

  • $_ post[‘log’]
  • $_ post[‘pwd’]
  • $_ post[‘rememberme’]

$secure_ cookie

Boolean, default: false

Do you want to use secure cookies

wp_ Example of using signon() function:

function custom_login() {
	$creds = array();
	$creds['user_login'] = 'example';
	$creds['user_password'] = 'plaintextpw';
	$creds['remember'] = true;
	$user = wp_signon( $creds, false );
	if ( is_wp_error($user) )
		echo $user->get_error_message();
// Set before loading headercookies
add_action( 'after_setup_theme', 'custom_login' );

Extended reading

wp_ The signon() function is located in: WP includes/ user.php

Related tags:

  • is_ user_ logged_ in()
  • wp_ login_ form()
  • 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