Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法使用wp_signon()_Php_Wordpress - Fatal编程技术网

Php 无法使用wp_signon()

Php 无法使用wp_signon(),php,wordpress,Php,Wordpress,当我尝试这个代码时 $creds = array( 'user_login' => $_POST['benutzername'], 'user_password' => $_POST['passwort'], 'remember' => true ); $user = wp_signon( $creds, false ); if ( is_wp_error($user) ): echo $user->get_error_message(); endif; wp_set_

当我尝试这个代码时

$creds = array( 'user_login' =>  $_POST['benutzername'], 'user_password' => $_POST['passwort'], 'remember' => true );
$user = wp_signon( $creds, false );
if ( is_wp_error($user) ): echo $user->get_error_message(); endif;
wp_set_current_user($user->ID);
return $user;
我得到这个信息:

警告:无法修改标题信息-标题已由发送 (输出开始于 /home/httpd/vhosts/your click.ch/httpdocs/wp includes/formatting.php:4179) 在/home/httpd/vhosts/your-click.ch/httpdocs/wp-includes/pluggable.php中 第925行警告:无法修改标题信息-标题 已由发送(输出开始于) /home/httpd/vhosts/your click.ch/httpdocs/wp includes/formatting.php:4179) 在/home/httpd/vhosts/your-click.ch/httpdocs/wp-includes/pluggable.php中 第926行警告:无法修改标题信息-标题 已由发送(输出开始于) /home/httpd/vhosts/your click.ch/httpdocs/wp includes/formatting.php:4179) 在/home/httpd/vhosts/your-click.ch/httpdocs/wp-includes/pluggable.php中 第927行出现可捕获的致命错误:类WP_用户的对象无法捕获 在中转换为字符串 /home/httpd/vhosts/your-click.ch/httpdocs/wp-includes/shortcodes.php 在线286


我正在shortcode.php中使用该代码。我的代码有什么问题?

根据功能的WP手册:

此函数用于向页面发送标题。它必须先运行,然后再运行 返回内容

根据您得到的错误,您似乎在返回某些内容后才使用此函数

此外,WP团队建议在设置主题后的钩子
中使用该功能,该主题:

将使其在发送标头和Cookie之前运行,以便 设置登录所需的cookie