WordPress.org

Ready to get started?Download WordPress

Forums

php if ... or ... (3 posts)

  1. Elliotvs
    Member
    Posted 2 years ago #

    Hello,

    Please could someone tell me how to make it so I can have this:

    <?php if (current_user_can('1')) { ?>
    
    or
    
    <?php if (current_user_can('2')) { ?>
    
    <?php } else { ?>
    
    Content if they can not do either of them.
    
    <?php } ?>

    Thanks,

    Elliot

  2. Digital Raindrops
    Member
    Posted 2 years ago #

    ! = not
    && = and
    || = or

    : = then instead of { }

    So you would write:

    <?php if ( current_user_can('1') || current_user_can('2') ) : ?>
    
    <?php else: ?>
    
    <?php endif; ?>

    HTH Examples

    David

  3. Elliotvs
    Member
    Posted 2 years ago #

    Thanks alot David.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.