How do I add the new field to the user's data? (avatar) - wordpress

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?

Related

How to know other users displayName and photo url using Firebase?

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.

How do I create a new page for each user?

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

Add Favourites to create a list then email list as part of an enquiry form

I have a client that wants a property directory, but they want users to be able to favourite multiple properties - then view their favourite properties on separate page - then send all those properties to a single email address as part of an enquiry.
cannot see how to do this using agentpress framework
You have two options, the first is to save as properties in session. The second if users are logged in to Wordpress is to use admin-ajax to add the properties as a meta data of the user. So this way you can access these meta infos using get_user_meta();
Documentation:
https://codex.wordpress.org/Function_Reference/get_user_meta
https://codex.wordpress.org/Function_Reference/add_user_meta
https://codex.wordpress.org/Function_Reference/update_user_meta

Create a contact form and display submissions as searchable directory

I want to create a directory that users can submit their data (name, email, phone) to and see a searchable directory. Ninja Forms was good for submitting data, but had no (free) option to display the data in a searchable format. I tried using Contact Form DB, but the displayed results weren't searchable.
The Gravity Forms plugin has an API that will allow you to access submitted data. Here is a similar query to your own:
https://wordpress.stackexchange.com/questions/82791/how-do-i-show-data-from-gravity-forms-in-my-template
That said, it would probably be just as easy (if not easier) to code this outside the WordPress framework. Create a new table in the database for user data, then create the corresponding form and PHP form handler to write the details to the table.
WordPress provides a class for explicitly accessing the database:
http://codex.wordpress.org/Class_Reference/wpdb
You would then simply add your search code into a page template. I hope this helps!

Imagecache dynamic generation with cck computed field

I'm having trouble with making a complex action with a CCK field.
The user provides a video id; then, using a cck compute field, i'm generating the unique hash to find the thumbnail of the image on the remote site; then, i don't know how to do this, but i want to 'fill up' a field (image type) with downloaded thumbnail and displayed with an image cache preset.
So my question may be dumb, but, how can I 'automatically' add an image to a image field using simple php function (that i'll put in the calculated cck field)
Use actions ? Or any other idea ?
Embedded Media Field works with ImageCache. It pulls the source image from a remote site, and can display it through imagecache instead of directly to the screen.
Using this approach, rather than computed field I would create an em field on the node, but hide it from the user. Instead, the user sees a text field for video ID, which is transformed on hook_nodeapi() presave op to populate the hidden em field.
If instead you do need to directly download your image, I would check out the FileField Sources module. It facilitates the user entering a remote url that will then be downloaded to the server. Perhaps you could use it as a sort of inspiration for your own small module to achieve this, or depending on how it's written, an API for your use.

Resources