Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i have this code to limit the comments per user.

<!-- #only one comment -->
<?php global $current_user,$post;
$usercomment = get_comments(array('author_email' => $current_user->user_email, 'post_id' => $post->ID));
if($usercomment) {
    echo "Thank you!";
}
else {
    comment_form();
}
 ?>

How can edit this code to also check if a custom user profile field [phone] is empty? If is empty display a message else display the comment form.

Thank you.

share|improve this question

1 Answer 1

get_the_author_meta( 'customfield' ) should give you the information that you can use in your conditional. Assuming customfield would be replaced by phone or whatever your custom field is named.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.