I am building a forum-like mobile application with flutter. When uploading a post, i saved the user details such as username, profile picture and details of the post into firebase as fields for that post's document. (Username and profile picture of the person who posted will be shown on the post) However, when i change my profile picture or username afterwards in settings, those appearing on the post were not updated accordingly. How do i rectify this such that relevant changes to user information will apply to the posts?
This is a snippet of how i had saved the data. I understand why the corresponding data will not update but i am not sure how to go about restructuring the code.
you can use a StreamController for this purpose. define a StreamController at application scope. you can subscribe to the stream at the widget where you are showing the profile picture and you can write to the stream when you update the profile picture from another widget, once you write to the stream, the subscribed widget will get the information and you can update the image using this information.
Related
I'm developing a review site.
I'm attempting to show a poster's displayName and photo, which means whatever people login in or not, any guys can see the poster's displayName and photo. The poster first log in and then post a review. other guys can see the post content, the poster's displayName, and photo url. How can you achieve it with Firebase Auth and Firestore?
I know that I can do it by using getUser or getUsers function from this ticket.
How to retrieve another user's info like email and displayName in Firebase?
However, those functions seems to be for admin so it's not good to use it in the above case due to security issue.
Any advice?
Firebase admin SDK is only to use on server side. If you want to have a poster display name and photo, just add it to a post he creates or create a collection with a poster's information in it. So when you get a post with owner uid you can again fetch data with poster information.
I recommend having first option because it needs just one read for users to make. And like I said in comment if user change some think you can find all his posts and change his display name or photo there. Feel less reliable, but in reality you don't want to have 50k reads instead of 25k out of poster 5 posts.
I'm developing a REST API with Wordpress. I had to develop a new one myself, ignoring the Gravatar method. Currently, users can upload images. But I have to somehow merge the avatar path with the user's data.
I need user_avatar field like user_login, user_nicename, user_url. I know, I can hide the path of the avatar file with the wp_usermeta of the user.
But I need to do more queries to get this information. To bypass this situation, I need to combine the relevant avatar path with the user's information. When I use the get_user() or get_users() methods, I want to see the user_avatar field in them.
Can I set this flow to appear in every query without breaking the database structure? Or do you have a better suggestion for it?
I have created an user from my app in Firebase:
and with it I also created some elements that I store in Firestore:
So as you can see, that elements is linked to this new user
If I go to Firestore db, all this elements are created ok but I don't know how to search by id, only by fields that I created for that user (email, name, etc):
As per Franks' answer, you can find a document/element with a specific ID by entering it in the little address bar/breadcrumb trail that sits above the data structure in the console. Pencil icon on the breadcrumbs are hidden by default, hover on the breadcrumbs for it to appear. By clicking on it, address bar will be shown. Enter a / and then the ID of the document/element.
For more detailed information, you can refer to this thread.
I need to create a new page for each user on signup so when you go to the site's explore page and click on someone's name or picture, it will take you to their specific page and display their data. (database is firebase firestore and firebase storage, saved link to each person's doc)
This is one of the issues I've been trying to fix for about a month(just fixed the explore page issue and got everyone profile pic to display with that individual user's name right below). I have tried making a new html page with someone's php and js script (didn't work, not familiar with php) and url rewriting.
I haven't been able to find anything else concrete or at least something else to point me in the right direction. Any pointers or tips?
(Vanilla/node.js)
With PHP, on clicking a persons username you can add the username as a parameter to the url e.g yoursite.com?user=personsusername then use GET method to retrieve the username and output data relating to that username from the database
I've created a view (Drupal 6) that gets put on the users profile page.
The view is supposed to list all the images that the user has uploaded. However, the view is showing every uploaded image by all users.
(When a user uploads an image, it first gets approved by me, and then posted by me and displayed on the homepage with a credit to them and a link to their user profile -- so they are not the "author" of the post, I always am.)
How can I limit the photos displaying on their user profile to just show the images uploaded by that particular user?
Thank you.
Use arguments handling: add argument - User ID, check "if argument not provided" and select php code: return arg(1); // if views shown as block and you want to show it in user profile, path will like user/UID, so arg(1) return UID.
2Ted: hello Ted! php code will absolutely secured, if you will check it, for example via is_numeric() function. Also users cann't get any images, becuase Views wil use Block display, and you cann't provide for this arguments directly.
2user967969: Additionally about approving: You can create second field, where you will store user profile UID. So for my above text you should use this field for argument handling, instead of user uid.