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. http://winaero.com/blog/move-the-comment-text-field-to-the-bottom-in-wordpress-4-4/
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.
A shortcut, if you want to call it that, would be to construct your own MySQL Query using $wpdb https://codex.wordpress.org/Class_Reference/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.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 29, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.