0

I made a custom admin bar that is displayed only for logged in users. But I just noticed that with "is_user_logged_in()" function it works only for admins and not contributors or spectators.

Here is my PHP and HTML code:

    <?php if ( is_user_logged_in() ) : ?>
        <a href="<?php global $current_user; echo home_url() . '/members/' . $current_user->user_login . '/profile/'; ?>">My profile</a>
        <a class="screen-reader-shortcut" href="<?php echo esc_url( wp_logout_url() ); ?>"><?php _e('Log out'); ?></a>
    <?php else: ?>
        <span>Become a member</span>
        <a href="/wp-login.php">Log in</a>
        <a class="cta-small" href="/register">Get invitation</a>
    <?php endif; ?>

Any ideas why it doesn't work?

I use Wordpress 5.2.1 and PHP 7.2

  • I am having same problem. @DanielsV.. Did u get a solution – Sujan Shrestha Aug 10 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.