Home Forums ACF PRO Fields to commentform


Fields to commentform

  • Hi,

    When adding fields to the commentform, how come custom fields are displayed above the normal fields for logged in users and underneath the normal fields for guests?

    That’s pretty inconsistent and i’d like for both to be the same!

    Any way to do this?

    Edit: if i add fields to the commentform, how would i query posts by the value in these fields?

  • I did some checking into this and it has to do with the displaying of the standard fields on the comment form.

    When the user is logged in the action is fired before the comment input.

    When a user is not logged in the name, email and website fields are shown. The hook will fire after these fields and before the comment input field. However, since by default the name, email and website fields are after the comment field, which is a recent change by WP, the hook does not fire before the comment field and still fires after the name, email and website fields. Until WP changed its behavior the fields in ACF would always appear above the comment field. If you change the order back to the way is used to be then you then it works this way. I found this post that does the trick.

    I don’t know if this is a bug or not, or even if the developer can do anything about it.

  • John, i think i read somewhere they decided it was best for the commentform textarea to appear on top – pretty recently (im thinking since 4.4).

    Moving the textarea down will place the fields between name/email/url and textarea .. it’s not that pretty. Is there no way to just stick them on top regardless?

    Also did you read my edit? 🙂

    if i add fields to the commentform, how would i query posts by the value in these fields?

    Thanks for your help.

  • I have posted an issue about the location of the fields on the github forum and brought this to the developer’s attention, I know this change was very recent and maybe there is something that can be done. I don’t know if there’s a fix for it or not as ACF needs to run on some hook in the comment form in order to work. I’m not familiar with the hooks in the comment form.

    As far as querying posts by custom fields on the comments, I don’t know if that’s possible, since they are attached to the comments and not the posts. I think you would need to query the comments and get a list of unique post ID’s and then use a post__in query for the posts.

  • Ok awesome, i’ll keep an eye on this thread! 🙂

    About the querying, i figured so much but wondered if there might have been a shortcut or something 🙂

  • A shortcut, if you want to call it that, would be to construct your own MySQL Query using $wpdb This would allow you to join the posts table, the comments and the comment meta table and return posts that have specific values associated with comments. It would perform faster, but would take more work to get working. I’m not very proficient at using $wpdb.

  • I’ve gotten a reply from the developer on this and it should be corrected in the next release.

  • John,

    Thanks for the follow up!

    Do you know if “the next release” is going to be 4.6 or 4.5.1?

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘Fields to commentform’ is closed to new replies.