Hello @codings,
The profile tab “Comments” retrieves comments by the user_id
parameter that should match the profile owner user_id
. When guests leave a comment this comment is saved with empty user_id
.
You can override the comments.php template in your theme to use the author_email
parameter instead of the user_id
. This doc describes how to override UM templates – Template structure & Overriding templates via a theme.
Try to paste this code to the file wp-content/themes/{active_theme}/ultimate-member/profile/comments.php
<?php
/**
* Template for the profile comments
*
* Copy this file to yourtheme/ultimate-member/profile/comments.php to override default comments.php template.
*
* @version 2.6.1
*
* @var int $count_comments
* @var object $comments
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$user_id = ! empty( $_POST['user_id'] ) ? absint( $_POST['user_id'] ) : um_profile_id();
$page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
$comments = get_comments( array(
'number' => 10,
'offset' => ( $page - 1 ) * 10,
'author_email' => um_profile( 'user_email' ),
'post_status' => array('publish'),
'type__not_in' => apply_filters( 'um_excluded_comment_types', array('') ),
) );
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
//Only for AJAX loading posts
if ( ! empty( $comments ) ) {
foreach ( $comments as $comment ) {
UM()->get_template( 'profile/comments-single.php', '', array( 'comment' => $comment ), true );
}
}
} else {
if ( ! empty( $comments ) ) { ?>
<div class="um-ajax-items">
<?php foreach ( $comments as $comment ) {
UM()->get_template( 'profile/comments-single.php', '', array( 'comment' => $comment ), true );
}
if ( $count_comments > 10 ) { ?>
<div class="um-load-items">
<a href="javascript:void(0);" class="um-ajax-paginate um-button" data-hook="um_load_comments"
data-user_id="<?php echo esc_attr( um_get_requested_user() ); ?>" data-page="1"
data-pages="<?php echo esc_attr( ceil( $count_comments / 10 ) ); ?>">
<?php _e( 'load more comments', 'ultimate-member' ); ?>
</a>
</div>
<?php } ?>
</div>
<?php } else { ?>
<div class="um-profile-note">
<span>
<?php if ( um_profile_id() == get_current_user_id() ) {
_e( 'You have not made any comments.', 'ultimate-member' );
} else {
_e( 'This user has not made any comments.', 'ultimate-member' );
} ?>
</span>
</div>
<?php }
}
Regards