Title: Get custom post comment
Last modified: December 20, 2021

---

# Get custom post comment

 *  [calaiopee](https://wordpress.org/support/users/calaiopee/)
 * (@calaiopee)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/get-custom-post-comment/)
 * Hi,
 * I have a buddyboss community running and I have several admins for certain sections.
   Each of these admins can edit a custom post type unique to this admin and section.
   These cpt posts can have comments. Now I need the comments table in the dashboard
   to show ONLY those comments, that are related to the post type of the actual 
   logged in admin user. As an idea I need something like this:
 * function get_admin_related_post_type_comment() {
    if HAS_COMMENTS_AT_ALL start
   loop:
 * if: current_user_has_role: „admin_cookbook“
    show comments to post_cookbuch AND
   hide all other comments
 * elseif: current_user_has_role: „admin_nonfiction“
    show comments to post_nonfiction
   AND hide all other comments
 * elseif: current_user_has_role: „admin_memoire“
    show comments to post_memoire
   AND hide all other comments
 * elseif: current_user_has_role: „admin_childrensbook“
    show comments to post_childrensbook
   AND hide all other comments
 * elseif: current_user_has_role: „administrator“
    show all comments EXCEPT comments
   to post_cookbook, post_nonfiction, post_memoire, post_childrensbook.
 * else: stop loop.
    }
 * Anybody help me with this?
 * Thanks
    Cally
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fget-custom-post-comment%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/get-custom-post-comment/#post-15182377)
 * Since that is a commercial plugin, we ask that you please go to their official
   support channel, so you can get support from the people who know it best: [https://my.buddyboss.com](https://my.buddyboss.com)
 * Forum volunteers are not given access to commercial products, so they would not
   know how it operates. Other community members who may have faced your issue might
   be able to help you but your best bet is your product’s developer. Keep in mind
   we encourage you to use the official support venues, as it allows the developers
   to be aware of issues with their code and gives back to the community in a more
   robust way.
 *  Thread Starter [calaiopee](https://wordpress.org/support/users/calaiopee/)
 * (@calaiopee)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/get-custom-post-comment/#post-15184294)
 * Hi James, thats true.
 * But what I need support for is not part of the plugin.
 * It’s a customization of the class-wp-post-comments-list-table.php in wordpress
   admin/includes folder. That class fetches the list of all comments and puts them
   in the dashboard table.
    I need it to first check the user role and fetch only
   the user roles related custom post types comments.
 * This does not depend on any plugin. Right?
 * Thanks for your patience 🙂
    Cally
 *  [Samuel O.](https://wordpress.org/support/users/wpcoworker/)
 * (@wpcoworker)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/get-custom-post-comment/#post-15203190)
 * Hi [@calaiopee](https://wordpress.org/support/users/calaiopee/) – you can use
   [`pre_get_comments` action hook](https://developer.wordpress.org/reference/hooks/pre_get_comments/)
   to filter the comments on comments screen of WordPress dashboard.
 * In the function attached to the hook you need to check the currently logged in
   user and accordingly pass the post type in query_vars.
 * I hope this helps.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Get custom post comment’ is closed to new replies.

## Tags

 * [custom comment](https://wordpress.org/support/topic-tag/custom-comment/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [Samuel O.](https://wordpress.org/support/users/wpcoworker/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/get-custom-post-comment/#post-15203190)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
