• Hello everyone. I’m wondering if you can help with a small query. I’ve installed BuddyPress on my site and have created a profile field called ‘Job Title’ that users have to fill out when they register (along with name, email etc.). Is there a way to customise the comments section of a blog post so that this profile field (Job Title) is shown along with the user’s name?

    (I’ve uploaded a mock image on IMGUR: https://imgur.com/G4xNHFi).

    At the top is an image of what a regular comment looks like from a registered user on my site. Below that is what I want – it’s just like a regular comment but it also includes the user’s job title (which is to be pulled from the user’s profile). Any idea how I can go about doing this?

    • This topic was modified 6 years, 2 months ago by Jan Dembowski.
Viewing 2 replies - 1 through 2 (of 2 total)
  • @bibblybob

    As far as I can tell there are no hooks available in WordPress to call and then insert that content.

    The most basic way of doing it is therefore to edit your themes files to collect that data from the custom field data stored in the database and then output it.

    Moderator bcworkz

    (@bcworkz)

    There actually is a hook of sorts, though not in the way mattyrob is thinking. They are correct in that there is no direct hook. However, you can use ‘wp_list_comments_args’ filter to pass a custom callback function that generates comment output. This is assuming your theme calls wp_list_comments() to generate the comments output. Most themes do, but it’s not universal.

    To create an appropriate callback, you could start with the source code for Walker_Comment::html5_comment() and modify to suit your needs.

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

The topic ‘Custom field in comments section’ is closed to new replies.