简体   繁体   中英

PHP - Display text if checkbox selected

I am using the user registration plugin ( https://wpeverest.com/wordpress-plugins/user-registration/ ). When a user signs up, there is an option to ask them if they're 'new team' or not. If they check 'new team' I then want to display text when they are signed in.

I have tried the following:-

<?php   
    $user = wp_get_current_user();
    if ( in_array( 'msp_team', (array) $user->user_registration_msp_team ) ) {
        echo ('TESTTTT');
    }
?>

But the text is not displaying. Could someone please advise what I am doing wrong here?

Thank you!

Managed to sort this with the following code:-

<?php if ( get_field( 'user_registration_msp_team', 'user_' . $current_user->ID ) ): ?>

FIELD CODE....

<?php else: ?>

OTHER CONTENT IF FIELD IS EMPTY

<?php endif;  ?>        

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