且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

wordpress wp_signon 功能不起作用

更新时间:2023-08-22 22:14:40

wp_signon() 需要在您将任何实际页面发送到浏览器之前运行.

wp_signon() needs to run before you've sent any of your actual page to the browser.

这是因为 wp_signon() 所做的部分工作是设置您的身份验证 cookie.它通过输出一个 "Set-Cookie: ..." 标头来实现这一点——如果你查看 pluggable.php 的第 690 行,你的错误来自哪里,你会看到那行设置一个饼干.

This is because part of what wp_signon() does is to set your authentication cookies. It does this by outputting a "Set-Cookie: ..." header -- if you look at line 690 of pluggable.php, where your error comes from, you'll see that that line sets a cookie.

所以,因为 wp_signon() 输出 headers,你不能已经发送任何 content -- 因为必须总是输出 headers在内容之前.

So, because wp_signon() outputs headers, you can't already have sent any content -- because headers must always be output before content.

但是,该错误表明您已经发送了一些输出——在 header.php 的第 12 行,大概是标准 WordPress 主题的一些第一个 HTML.

However, the error indicates that you've already sent some output -- on line 12 of header.php, presumably some of the first HTML of the standard WordPress theme.

这基本上表明您需要将 wp_signon() 调用移动到 WordPress 处理中较早的某个位置,因此它有机会在发送任何页面内容之前输出其标题.

This basically indicates that you need to move your wp_signon() call to somewhere earlier in the WordPress processing, so it has a chance to output its headers before any page content is sent.