is_user_logged_in() not working ?
-
Hey guys, I’m just trying to show “test” when the user is connected and the button when he’s not, but no matter if I’m connected or not, mobile or desktop, it always shows both.
I’m using the HTML widget in elementor pro, here’s my code :
HTML/PHP
<?php add_action(‘init’, ‘ajax_auth_init’);
function ajax_auth_init()
{
if(is_user_logged_in()) return; ?>
<div class=”.logged in .dejaconnecte”>Test </div>
<div class=”.logged in .rejoindreevapy”>Join</div><?php ; ?>
<?php $(“.logged in .rejoindreevapy”).hide(); ?>
<?php
}else {?>
<div class=”dejaconnecte”></div>
<div class=”rejoindreevapy”></div>
<?php $(“dejaconnecte”).hide(); ?> <?php ; ?>
<?php } ?>CSS
<–logged out–>
.rejoindreevapy {
margin-left: auto;
margin-right: auto;
width: 49%;
}.dejaconnecte {
display: none;
}<–logged in–>
.logged-in .rejoindreevapy {
display: none;
}.logged-in .dejaconnecte {
margin-left: auto;
margin-right: auto;
display: inline;
}
The topic ‘is_user_logged_in() not working ?’ is closed to new replies.