简体   繁体   中英

PHP if/then statement

Need help with some php to modify a WP plugin which is paid memberships pro. Terrible at php here.

What am trying to do is create one line of code that would say if the membership level equals XXX then print this link. SO the variable I would need are somewhere in this line I imagine:

<li><strong><?php _e('Membership Level', 'paid-memberships-pro' );?>:
</strong> <?php echo $current_user->membership_level->name?></li>

The above is just a snippet of code already found in the page I want to create this if/then link statement.

so something like:

<?php if($Membership Level == $Conflicts of Interest #14124(that's the name 
of one level) then print this link.

AM I making sense?

Edit:

Thanks to some help below, this seems to work:

<?php if($membership_level == 'Conflicts of Interest #14124') {
echo "<a href=\"conflicts-of-interest-in-modern-legal-practice-and-internal-
investigations-14124/\">Testing</a>";
}
?>

But the 'Conflicts of Interest #14124' doesn't match even though it is the correct name.

Then general If else statement in the html page

<?php if($membership_level == 'string to be compared') {
    echo 'the link that you want to print if it is a string. you can replace this string 
          with a variable if the value is in variable'
} else {
   'any other text if require else you can remove the else block'
}
?>

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM