Only display comments from registered users
-
What are you using to display the comments?
wp_list_comments
or something else? Is it a custom query?If you’re using
wp_list_comments
, it uses the queried comments by default. Inquery.php
on line 2961 there is a filter you can use to add your condition:comment_feed_where
.You should be able to do something like this: https://gist.github.com/nickohrn/9311741
This is untested, but should work. Please let me know if you have any questions.
Hi there,
Thank-you for getting back to me 🙂
Yes I am using
wp_list_comments
with the below code:/** * Loop through and list the comments. Tell wp_list_comments() * to use phpbb_comment_loop() to format the comments. */ $defaults = array( 'walker' => null, 'max_depth' => '', 'style' => 'div', 'callback' => 'wp_phpbb_comment_loop', 'end-callback' => 'wp_phpbb_comment_end_el', 'type' => 'all', 'page' => '', 'per_page' => '', 'avatar_size' => phpbb::$config['wp_phpbb_bridge_comments_avatar_width'], 'reverse_top_level' => null, 'reverse_children' => '' ); wp_list_comments($defaults);
I’m displaying the comments that that post on single.php. The above code that I provided is out of comment.php and that file is being included in single.php.
I’ll give the code you provided a try when I get home tonight and let you know how it goes.
Daniel, did this work for you?
Hi there,
Sorry about the late reply. I got caught up in a large project that went badly wrong.
I tried what you suggested and I’m afraid that it’s not working for me at all. I got a feeling that it may not work because of the fact that I’m calling up all the WordPress stuff in a completely different way that is not native.
I got my single.php and comment.php on github. Please be mindful that it’s not the latest version but the problem still show up on it.
Yeah, that’s a tough one. I don’t have time to dig into this the way I would need to, so I wish you luck figuring it out!
- The topic ‘Only display comments from registered users’ is closed to new replies.
(@danielx64)
10 years, 1 month ago
Hi there,
I got a question, I’m working on a system where it bridge up with phpBB and everything is working just fine, well almost.
I got a nasty bug that I can’t fix (and it may never be) and I have discovered that it caused by people who got a user_id of 0 in the wp_comments table.
The way that I was going to work around this is to
add AND >= '1'
to the sql statement that produce the comments.My problem is, I’m not sure how I can go about hooking into it without having to hack the core.
Does anyone have any ideas on how I can add the extra sql needed?
Thank-you 🙂
PS, this is going into a wordpress theme but I feel that it belong here as it hacking the core and this sort of thing is really done via plugins.