I’m facing a small issue with my front-end form. The form publishes everything perfectly but I’m unable to add a new Taxonomy.
So the functionality I’m trying to provide is a way for non-logged-in users to add a new Industry taxonomy from the front-end. This works perfectly in the backend. A + icon appears, click it, popup box appears, type the Industry name, click Add, done. Perfect. However, on the front-end the + icon appears (when logged in) but clicking it does not show the popup box.
I don’t see any JS errors or anything that makes me think a script is not loaded. I’m just not sure what’s going on.
The field I’m using is a Taxonomy field with the Create, Save and Load Terms checked. I’ve tried setting the field to be a Checkbox or Multi Select. The issue happens either way.
So really I guess there are 2 issues:
1. Any idea what I could be missing as to why the + icon does not open the popup on the front-end?
2. How would allow non-logged-in users access to create terms?
Any help or points in the right direction would be much appreciated.
In order to add terms to a taxonomy a user must have the correct permissions to do so. In WP for categories this would be
manage_categories. I doubt that there is any way to give this permission to non logged in users.
What you would need to do is set up some other type of field, a text field for example where they can enter either one new term or possible a comma separated list, or maybe a repeater. Then use an acf/save_post filter to get the new terms to be added and use WP set post terms to update the post https://codex.wordpress.org/Function_Reference/wp_set_post_terms
This is a related question (tell me if I rather should open a new issue instead):
In order to add terms to a taxonomy a user must have the correct permissions to do so. In WP for categories this would be manage_categories.
I have a logged in user with the
manage_categories capability but I still do not see the ability to add new terms from the front-end. Is there any other capability that is needed as well?
Well, the weird part was caused by my code, it seems 🙂
This is how it works: ACF is checking the
At first I didn’t understand because
manage_terms is not listed here:
It’s also not available in the User Role Editor plugin, which I was using to assign capabilities to roles.
manage_terms is a special capability that is created when you use
register_taxonomy() to register a taxonomy:
It is set up as a reference to another capability, in the example it is
manage_categories. But in my case I had a custom taxonomy where the
manage_terms was set to
edit_users for some reason, and that explains it all!
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.