Support

Account

Home Forums General Issues Update Taxonomy With ACF Fields Reply To: Update Taxonomy With ACF Fields

  • How would I do this if I had to do it.

    I would create a true false field “Add New Member”

    Then I would create 3 fields Name, Slug and Description. These 3 fields would be conditional and only show if Add New Member is true, these fields would all be required.

    Then I would create an acf/save_post filter https://www.advancedcustomfields.com/resources/acf-save_post/. In this filter I would

    1. see if the add new member field was set
    2. if it is I would get the values from the other 3 fields
    3. I would use these values to create a new term https://codex.wordpress.org/Function_Reference/wp_insert_term
    4. Then I would add this term to the post https://codex.wordpress.org/Function_Reference/wp_set_post_terms
    5. And finally I would delete the values from the 3 ACF fields and update the add new member field to false

    But to be honest, I would not probably do this unless I had a client that insisted on it. I would tell them that before they add a new post for a member that does not exist that first they must add the member. Or I would tell them that they will need to go to the member when they are done with adding the post and add a description for the member after the fact. This is no different than adding a category, or (product category in woocommerce), the only thing that you can do is add the name and then you need to go to that category and add a description and other information if the site needs it later.