我看到了这个错误
未定义索引: /home/olexywro/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(352):eval()d代码中的操作(第6行)
在我的登录页面中,有以下代码片段:
// Redirect Registration Page
function my_registration_page_redirect()
{
global $pagenow;
if ( ( strtolower($pagenow) == 'wp-login.php') && ( strtolower( $_GET['action']) == 'register' ) ) {
wp_redirect( home_url('/zarejestruj-sie/'));
}
}
add_filter( 'init', 'my_registration_page_redirect' );有人能告诉我为什么吗?
代码的第6行:
if ( ( strtolower($pagenow) == 'wp-login.php') && ( strtolower( $_GET['action']) == 'register' ) ) {发布于 2018-09-16 11:26:31
你要这么做:
strtolower( $_GET['action'])但您并没有首先检查$_GET['action']是否存在。您不能指望它正在设置,因为当您访问wp-login.php时,它在URL中没有?action=,但是这个钩子仍然会触发。
因此,您需要在条件中添加isset( $_GET['action'] ):
if (
strtolower($pagenow) == 'wp-login.php' &&
isset( $_GET['action'] ) &&
strtolower( $_GET['action'] ) == 'register'
) {
}https://wordpress.stackexchange.com/questions/314327
复制相似问题