Я создаю плагин, где существует страница входа и регистрации (пользовательская страница с использованием шорткода).
Итак, я перенаправляю пользователя, если вошедший в систему пользователь перейдет на www.mysite.com/login страницу, так как это страница входа.
Но отображается следующая ошибка, когда я (как пользователь) go перехожу на эту страницу входа.
Предупреждение: невозможно изменить информацию заголовка - заголовки уже отправлены (вывод начался с C: \ laragon \ www\wp \ wp-includes \ class.wp-styles. php: 287) в C: \ laragon \ www\wp \ wp-includes \ pluggable. php в строке 1265
Предупреждение: невозможно изменить информацию заголовка - заголовки, уже отправленные (вывод начался с C: \ laragon \ www\wp \ wp-includes \ class.wp-styles. php: 287) в C: \ laragon \ www\wp \ wp-includes \ pluggable. php on line 1268
Код:
final class ShibbirDirectoryListing
{
public static function instance()
{
if (is_null(self::$instance)) {
self::$instance = new self();
self::$instance->setup();
}
return self::$instance;
}
public function setup()
{
$this->check_environment();
$this->define_constant();
$this->includes();
$this->init_hooks();
$this->plugin_init();
do_action('shibbir_directory_listing_loaded');
}
/**
* Include required core files which is used in both admin and frontend
*/
public function includes()
{
// Includes only in frontend
if( $this->is_request( 'frontend' ) ) {
include_once SDL_INCLUDES . '/class-shortcodes.php';
include_once SDL_INCLUDES . '/class-frontend.php';
}
}
}
/**
* Get the instance of the plugin
*/
function shibbir_directory_listing()
{
return ShibbirDirectoryListing::instance();
}
// Let's start the Engine
shibbir_directory_listing();
class-frontend. php file
<?php
namespace Shibbir\ShibbirDirectoryListing;
class ShortCode {
public function __construct() {
add_shortcode( 'sdl_login', array( $this, 'render_login_form' ) );
add_shortcode( 'sdl_registration', array( $this, 'render_registration_form' ) );
}
public function render_login_form() {
if( is_user_logged_in() ) {
wp_redirect( site_url( '/') );
exit;
}
include SDL_TEMPLATES_DIR . '/login-form.php';
}
}
С этой строки
if( is_user_logged_in() ) {
wp_redirect( site_url( '/') );
exit;
}
эти сообщения об ошибках показывают :(
Что-то я делаю не так?