vendredi 13 novembre 2015

if get_user_meta false not working

I have a checkbox in my template to enable ( checked ) or disable ( unchecked ) the shipping options.

My intention is to display a div with some information only if the checkbox is unchecked - shipping disabled.

I am trying to insert into my template and work with the following If statement:

<!-- Show DIV if checkbox is unchecked - false -->
<?php if( get_user_meta( $post->post_author, '_shipping_checkbox', false ) == 'yes' ) { ?>  
        <div id="info">
                  <p>Shipping is currently disabled</p>    
        </div>   
<?php } ?>

But that doesn't seem to work and the DIV is not showing up.

If I try and test it with TRUE instead of false, so if I check the checkbox and change the statement to true

<?php if( get_user_meta( $post->post_author, '_shipping_checkbox', true ) == 'yes' ) { ?>

Then the div is now showing up correctly.

What am I doing wrong here ?

Or should I be doing this different way ?

I am trying to avoid Jquery and Javascript, I just don't know how to work with scripts correctly.




Aucun commentaire:

Enregistrer un commentaire