Reputation: 11
I built my own comments.php
on my project. I want to get the comment author custom meta data in custom_comments.php
.
I search every page on Google, but have not found any answers.
This is my code:
<?php
$args = array (
'post_id' => $post_id
);
$comments = get_comments( $args );
if ( !empty( $comments ) ) :
foreach( $comments as $comment ) :
?>
<li>
<?php echo get_the_author_meta('mo_ldap_local_custom_attribute_title', $user->ID); ?>
</li>
<?php endforeach; endif; ?>
Upvotes: 0
Views: 1694
Reputation: 2597
For example, first get user name:
<?php $author = get_comment_author( $comment_ID ); ?>
From codex:
$user = get_user_by('login',$author);
if($user){
echo $user->ID;
$userID = $user->ID;
}
and then You can get author info by:
https://codex.wordpress.org/Function_Reference/the_author_meta
<?php the_author_meta( $field, $userID ); ?>
Upvotes: 1