Home Forums General Issues User field, front end button add user to field and update user


User field, front end button add user to field and update user

  • Hi all,

    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.

    Any help would be great!

  • Initial thoughts would be needing:

    – 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.