Answer the question
In order to leave comments, you need to log in
Why is is_user_logged_in() on the server throws an error but works on localhost?
I am writing one plugin and a strange thing with this function
function checkLogged(){
if ( !is_user_logged_in() ) {
wp_redirect(home_url('/wp-login') );
exit;
}
}
add_action('wp_head', 'checkLogged');
Warning: Cannot modify header information - headers already sent by (output started at .../wp-includes/formatting.php:4583) in .../wp-includes/pluggable.php on line 1228
Answer the question
In order to leave comments, you need to log in
Well, I asked myself and I'll answer it myself...
you need to change wp_head -> template_redirect
and everything works.
Because the redirect occurs due to the sending of headers Location
.
In your case, the headers cannot be sent because some information has already been output (this is written in the error message), in the file /wp-includes/formatting.php
on the 4583
. You can see what happens there - the config is connected, or some file with BOM.
Product and product_translations table with all fields that can be translated and the locale field.
If there are only two languages and no more are expected, then there are two fields in the table. If you need to expand languages, then a separate table (`product_id`, `language`, `name`)
More correctly so: separate tables for entities + language tables for them.
For example: products + products_i18n
In the first, all fields that do not depend on the language, in i18n - respectively, all dependent (usually text) on the language.
products: id, category_id
products_i18n: product_id, language_id, title
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question