Я добавляю некоторый код в functions.php (в редакторе тем WordPress, размещенном в движке wp), и в зависимости от того, где я размещаю wp_redirect, он будет сохранять или не сохранять
Пример: он будет сохранен, когда ясделать это
add_action('template_redirect','test_template');
//this one saves fine
function test_template() {
global $wp_query;
$userId = $wp_query->get( 'userId', NULL );
$url = get_site_url();
if ( NULL !== $userId ) {
wp_redirect($url);
exit;
}
}
//However, when I do this I get: "Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP."
function test_template() {
global $wp_query;
$userId = $wp_query->get( 'userId', NULL );
$url = get_site_url();
wp_redirect($url);
exit;
}
Не уверен, почему вторая функция не сохранит, какие-либо идеи?