MisterV
MisterV

Reputation: 3

Checking if a specific Wordpress user or no user is logged in conditional

I'm trying to construct a conditional statement that checks if a specific user or no user is logged in and displays specific output.

I have at the moment:

    <?php $current_user = wp_get_current_user(); ?>

    <?php if $current_user = 'PQ'() || if $current_user = ''(); ?>
    <span class="OrderNumber">#<?php echo types_render_field("user", array("raw"=>"true",)); ?>-<?php the_ID(); ?></span>
    <?php else ?>

    <span class="OrderNumber">#<?php echo $current_user->user_login; ?>-<?php the_ID(); ?></span>
    <?php endif ?>

Thanks

Upvotes: 0

Views: 272

Answers (1)

VeteranLK
VeteranLK

Reputation: 746

There's a built in function in WordPress. is_user_logged_in()

<?php
if ( is_user_logged_in() ) {
    //your code
} else {
    //please login
}
?>

additionally wp_login_form(); will displays a simple login dialog

Upvotes: 2

Related Questions