I have a property website with a custom search form for minimum and maximum square feet.
A registered user executes a search with a min(i.e. 150 sqft) and max(i.e. 300 sqft) select option value.
I managed already to store inside cookies the min and max values.
Then the user is able to click on a "save this search" button.
I would like to save those values inside the database and show them on each user's profile page (that I already created).
When the user goes to its profile page I'd like to have a list of all the saved searches.
I hope this makes sense.
Ideally the custom user page would look like this:
Saved Search 1: 150sq ft - 300 sq ft
Saved Search 2: 500sq ft - 800 sq ft
...
Is this possible? How would I do this?
I'm quite new at customising WordPress templates, I would really appreciate any help.
I have a property website with a custom search form for minimum and maximum square feet.
A registered user executes a search with a min(i.e. 150 sqft) and max(i.e. 300 sqft) select option value.
I managed already to store inside cookies the min and max values.
Then the user is able to click on a "save this search" button.
I would like to save those values inside the database and show them on each user's profile page (that I already created).
When the user goes to its profile page I'd like to have a list of all the saved searches.
I hope this makes sense.
Ideally the custom user page would look like this:
Saved Search 1: 150sq ft - 300 sq ft
Saved Search 2: 500sq ft - 800 sq ft
...
Is this possible? How would I do this?
I'm quite new at customising WordPress templates, I would really appreciate any help.
Assuming that those users have accounts on your site (are subscribers, authors, or some other role), you can add custom fields to their profiles. The easiest way is to use a plugin, like Advanced Custom Fields (https://wordpress.org/plugins/advanced-custom-fields/).
The fields would be available in their profile pages, and you can add, and use in any template.
I would give you code examples, but their site seems to be down... I'll try to update the answer once it's up again.
Update: ACF could take care of creating the fields, and displaying them in the user profile page, and you can use add_user_meta to save them:
add_user_meta( $user_id, 'custom_field_name', $search);
If you don't want to use ACF, you can display the fields in the profile with custom code. Deleting the searches would be a bit harder, though, but doable.
Create a new post & save the search info as post meta-data, then reference it later by the post-id.
This gives us a backend solution, that could tie-in to the data you've mentioned saving, a front-end solution might consist of adding the data to window.localStorage
for later lookup & pre-population into the form inputs.