logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$4
Show/Hide statement for Woocommerce 'Paying Customers'

Need some help formatting an if statement that hides the comment area unless a customer has bought an item. This is where I am so far (I am new to code so I am sure there are some large gaps):


<div id="commentformcheck">
<?php
$paying_customer = get_user_meta( $user_id, 'paying_customer', true );
if ( $paying_customer) {?>
<div id="commentform">
<?php
myrp_api_comment_field_form_table();
myrp_api_ratings_form_table();
genesis_do_comment_form();
?>
</div>
<?php } else { ?>
<h3>You must make a purchase to leave a review</h3>
<?php} ?>


This part get_user_meta( $user_id, 'paying_customer', true ) was given to me by the woothemes support

This question has been answered.

ktrusak | 07/27/12 at 11:04am Edit


(3) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    07/27/12
    11:17am
    Michael Caputo says:



    <div id="commentformcheck">

    <?php

    $paying_customer = get_user_meta( $user_id, 'paying_customer', true );

    if ( $paying_customer != '' ) {?>

    <div id="commentform">

    <?php

    myrp_api_comment_field_form_table();

    myrp_api_ratings_form_table();

    genesis_do_comment_form();

    ?>

    </div>

    <?php } else { ?>

    <h3>You must make a purchase to leave a review</h3>

    <?php} ?>
    </div>

    Previous versions of this answer: 07/27/12 at 11:17am

    • 07/27/12 11:13am

      ktrusak says:

      It is still breaking the page when I insert that code

      Thanks for the reply

    • 07/27/12 11:17am

      Michael Caputo says:

      Any chance I can see the page where you're putting the code?

    • 07/27/12 11:17am

      Michael Caputo says:

      I added a closing div to my original code

  • avatar
    Last edited:
    07/27/12
    12:02pm
    Arnav Joy says:

    try this



    <div id="commentformcheck">

    <?php

    global $user_id;
    $paying_customer = get_user_meta( $user_id, 'paying_customer', true );

    if ( $paying_customer) {?>

    <div id="commentform">

    <?php

    myrp_api_comment_field_form_table();

    myrp_api_ratings_form_table();

    genesis_do_comment_form();

    ?>

    </div>

    <?php } else { ?>

    <h3>You must make a purchase to leave a review</h3>

    <?php} ?>

    • 07/27/12 12:06pm

      ktrusak says:

      Thanks for the reply

      It still isn't working though, I am not sure what is going wrong

    • 07/27/12 12:10pm

      Arnav Joy says:

      what you are getting right now..

      can you show me the url

      can you show whole code of the page

    • 07/27/12 1:22pm

      Arnav Joy says:

      try this

      http://pastie.org/4343751

      and if it does not works then provide me access to site i will make that correct

  • avatar
    Last edited:
    07/27/12
    3:38pm
    Martin Pham says:

    try this


    <div id="commentformcheck">

    <?php
    $user_id = get_current_user_id();
    $paying_customer = get_user_meta( $user_id, 'paying_customer', true );

    if ( $paying_customer) {?>

    <div id="commentform">

    <?php

    myrp_api_comment_field_form_table();

    myrp_api_ratings_form_table();

    genesis_do_comment_form();

    ?>

    </div>

    <?php } else { ?>

    <h3>You must make a purchase to leave a review</h3>

    <?php} ?>

    • 07/28/12 10:15am

      ktrusak says:

      This worked, thanks Martin

This question has expired.



Gabriel Reguly, Arnav Joy, Manoj Raj, ktrusak voted on this question.



Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.