wp_signon()设置指定的用户登陆

目录

描述

译文

授权给用户并可记住该用户名称。该函数取代了wp_login。WordPress 2.5版本起启用。

原文

Authenticates a user with option to remember credentials. Replaces deprecated function wp_login.

wp_signon() 描述

用法

 <?php wp_signon$credentials$secure_cookie ?> 

wp_signon() 用法

参数

$credentials

(array) (可选) User info in order to sign on.

默认值: None

$secure_cookie

(boolean) (可选) Whether to use secure cookie.

默认值: None

NOTE: If you don't provide $credentials, wp_signon uses the $_POST variable (the keys being "log", "pwd" and "rememberme").

wp_signon() 参数

示例

This function and action can be placed in functions.php of the theme.
Using the hook after_setup_theme will make it run before the headers and cookies are sent, so it can set the needed cookie for login.

wp_signon() 示例

注意

  • This function sends headers to the page. It must be run before any content is returned.
  • This function sets an authentication cookie. Users will not be logged in if it is not sent.

wp_signon() 注意

历史

添加于 版本: 2.5.0

wp_signon() 历史

源文件

wp_signon() 函数的代码位于 wp-includes/user.php.

wp_signon() 源文件