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
Martin Pham answers:
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} ?>
Kyle comments:
This worked, thanks Martin
Michael Caputo answers:
<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>
Kyle comments:
It is still breaking the page when I insert that code
Thanks for the reply
Michael Caputo comments:
Any chance I can see the page where you're putting the code?
Michael Caputo comments:
I added a closing div to my original code
Arnav Joy answers:
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} ?>
Kyle comments:
Thanks for the reply
It still isn't working though, I am not sure what is going wrong
Arnav Joy comments:
what you are getting right now..
can you show me the url
can you show whole code of the page
Arnav Joy comments:
try this
http://pastie.org/4343751
and if it does not works then provide me access to site i will make that correct