Hello,
I would like to create a “Favorites” feature on my website.
– I created an ACF group called “Favorites” with a “Relationship” field called “member_favorites”. The “Relationship” field is linked to a custom post type called “Classes”. The ACF group appears in any User profiles.
– I created a button in my CPT single “Classes” that makes an ajax call to a function “add_to_favorites”.
– With this function, I would like to update_field and add (if it’s not already in) or remove (if it’s already in) the current post type ID from my relationship field “member_favorites”.
I am basically looking for a toggle function to add or remove posts from a relationship field in my user profile. Can anyone help with this please 🙂