Navigation überspringen

[Gelöst] How to let the comments go to the account page automatically based on the same post author?

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

How to let the comments go to the account page automatically based on the same post author?

Solution:

It needs custom codes, for example:

https://toolset.com/forums/topic/how-to-let-the-comments-go-to-the-account-page-automatically-based-on-the-same-post-author/#post-1569007

Relevant Documentation:

This support ticket is created vor 5 Jahren, 2 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von FuChan vor 5 Jahren, 1 Monat.

Assistiert von: Luo Yang.

Author
Artikel
#1568969

Thanks for your great help. One more thing I would like to trouble you again concerning the comments.

I am trying to use Toolset Layout to create account page for different users (authors). The comments received from the posts are put in the Dashboard=>Comments together. How to let the comments go to the account page automatically based on the same post author?

Are are available shortcodes or custom codes to use? Thanks again.

#1569007

Hello,

I assume you are going to display all comments which are belongs to posts, and those post's author is same as current logged-in user.

It needs to query the comment by post author parameter, but Toolset Views does not support this feature, so it needs custom codes, for example:
1) Create a custom shortcode, add below PHP codes into your theme file functions.php:

add_shortcode('my-post-comments', function($atts, $content){
	if(!get_current_user_id()){ // guest user
		return;
	}
	$args = array(
		'post_author' => get_current_user_id(), // It will use the current logged in use to grab the comments
	);
	$comments = get_comments( $args );

	// Referer to http://codex.wordpress.org/Function_Reference/wp_list_comments
	$list_args = array(
		'reverse_top_level' => false, // Show the latest comments at the top of the list
		'echo' => false,
	);
	$res = wp_list_comments( $list_args, $comments );
	return $res;
});

2) Display above shortcode like this:
[my-post-comments]

#1569723

My issue is resolved now. Thank you!