Hi guys, I am trying to build a community based website and I am developing a custom Members area. I am stuck at the moment trying to save member posts with their _id to a different database where I hold all of the posts created by users (please let me know if this is inefficient and if you have a better suggestion for storing users posts)
The reason being is I want to retrieve the posts made by the user and display them onto their personal account for everyone to see. Like your personal timeline on facebook or your tweets on twitter. I want to put a filter on a dataset on the members dynamic page, this dataset is connected to a repeater which spits out the posts.
When I go to create a filter I only get an option to set owner as the logged in user, this results in posts on every individual page being that of the logged in user and not the members posts that the user is looking at.
User A logs into the site, every other users page that they look at they are shown posts which they (User A) themselves has posted and not the other user. (I hope that makes sense)
SO HERE'S MY ATTEMPT TO WORKAROUND THIS
In my collection_ProfileStatuses I have added a field "userId"
In my collection_ProfileData I have added a field "userId"
When users are creating a post I do the following
hide an element $w('#input1') and set its value to wixUsers.currentUser.id;(this allows me to track the current logged in user who is writing the post)
save their post from $w('#textBox1').value to the field "statusText" in collection_ProfileStatuses
set $w('#input1').value to the field "userId" in collection_ProfileStatuses (this is now the _id of the user who has written the post, this is the exact same as the "_owner" field)
now for the part I am stuck on!
in my collection _ProfileData I need to set the field "userId" to the "_id" of that user.
This will allow me to set a filter to $w('#statuses) which looks like this. Yielding the desired result of showing an individuals posts on their page.
here is my latest attempt which does not work. Everything has been spell checked!!
I have tried a few different ways with minimal success, I have years of coding experience however I only consider myself a novice.
The main thing I need to achieve here is to set the field "userId" to "_id" of the same user. Other attempts resulted in it being set the the current logged in user. which is of course incorrect.
I have thought about using hooks but am ensure if this would be ideal and my knowledge is limited in the area. My main problem is getting and setting data from fields.
THANK YOU IN ADVANCE,