php - how to solve header location warning wordpress
问题描述
Hi I want to create a simple login code to redirect each user to his own profile page.
I'm using a page "CleanPage" as a template for my php code.
I tried header Location
and wp_redirect
but both shows this error:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/general-template.php:1076) in /var/www/html/wp-content/themes/sydney/CleanPage.php on line 43
I wanted simple redirection like this:
header("Location: auth_customer.php?id=$userid");
Any help please?
解决方案
虽然我已经在上面的评论部分发布了链接。我相信这绝对可以解决您的问题
<?php
add_action( 'send_headers', 'add_header_xua' );
function add_header_xua() {
// your login logic or whatever should go here
// ....
header("Location: auth_customer.php?id=$userid");
}
推荐阅读
- .net-core - Active Directory 登录不起作用,出现错误“请求中指定的回复 URL 与为应用程序配置的回复 URL 不匹配”
- laravel - 我想创建一对多关系 | If 条件 | (类别有很多子类别)
- linux - 如何在 linux 系统的可执行文件上设置图标(或 .ico 文件)?
- python - TypeError: __init__() 缺少 4 个必需的位置参数:
- python - 执行 python try-except 部分时出错
- regex - htaccess regex - FilesMatch 使用来自 url/最后一个斜杠之后的最后一个目录的字符串
- java - 如何以 vertx-junit5 的方式放置关于 RunTestOnContext 的 vertx @Rule?
- ios - 如何在 AVplayerViewController 中添加播放和字幕控制?
- c++ - 我可以在 C++ 中有一个非虚拟抽象类吗
- cordova - 如何修复 UIWebView 已弃用的 Ionic 3