This is an odd request. I’m trying to make a pseudo like/follow functionality on a membership site using ACF.
I have gotten it to display the liked/followed user from a user field within the backend. I now need to build a button that I can add to all users profile pages that will allow the user to like/follow that user, which will add to their user field within their own profile and update it all in one go.
Any ideas on how this can be done? I’ve not found anything on my initial searches.
– User ID for current user (you’d be updating the meta for this user with the followed user’s ID) — something like get_current_user_id()
– User ID of user being viewed (value that would be added to the meta key of the logged in user if they click the button)
With those bits of data, you could likely:
– use get_user_meta() to grab the current IDs (if any) of the field storing followed/liked users from the current logged in user
– use something like maybe array_push to add the user ID of the user being viewed to the logged in user’s followed/liked group
– update_user_meta() with the new value
If you have a function written that does this, the function could then be triggered with the button click. Not sure if any of this is helpful but hopefully 🙂
Viewing 2 posts - 1 through 2 (of 2 total)
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
2022 was a big year for Advanced Custom Fields, with more capabilities, a new generation of ACF Blocks, a refreshed UI, and a new home. Our year in review post looks at advancements we’ve made and offers a glimpse of the future. https://t.co/HahJUCcyH4