How to create a subscribe/follow button for user posts using Memberstack and Webflow CMS?

Post author
Jack Ellis

Does anyone know how to create a subscribe/follow button using memberstack? So that the user's latest posts go into a cms collection that can be filtered? Something like the memberstack and webflow social media build, but with the ability to follow/unfollow certain people and see their latest posts?

Comments

4 comments

  • Comment author
    Abdullateef Ademoye

    Jack Ellis you can use the json feature to hold the array of userId of user I followed so as to see their post, if unfollowed then you remove the userId from the array.

    0
  • Comment author
    Jack Ellis

    Do you know how to remove the userID from the array? I figured out how to add it but not remove it

    Thanks!

    0
  • Comment author
    Abdullateef Ademoye
    you can use javascript array filter method to do that, then save it back to memberstack (edited) 
     
    Jack Ellis Something like
    Assuming your current user id array is:
    const existingUserIdList = [1,2,3,4,5]
     
    Then the userId you want to remove is 3
    const userIdToRemove = 3
     
    const validUserIdList = existingUserIdList.filter(userId => userId !== userIdToRemove)
    then save the new validUserIdList
    that will give you what is needed.
    0
  • Comment author
    Jack Ellis

    Thank you so much! Appreciate the help

    I'm still stuck on this... I'll give you more context. I'm using this script (https://www.memberstack.com/scripts/add-items-to-member-json) to add items to a json list. So in a member's json it shows {
    "subscriptions": [
    "668ab58....",
    "666399f...",
    "668bfb56....",
    ]
    } Adding the json items works fine. Though, I'm trying to display a button for subscribe and unsubscribe. So if CMS ID matches with one of the subscription CMS IDs it'll show the unsubscribe button and the user will be able to remove the item from their json list by clicking it. I don't even know where to start when checking to see if a value matches the member's json list and then removing it

    Any help would be greatly appreciated!
    0

Please sign in to leave a comment.