Skip Navigation

[Resolved] User stored preference data, changes search results

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 13 replies, has 2 voices.

Last updated by Minesh 5 months, 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2706764

I'm making a website that gets more and more complex.

What I'm trying to do: User saves data (custom fields) as changeable preference in their user profile and based on them - get specific results.

I have a field "city" and taxonomy "listing categories", both made from other plugin.
And i need both as checkboxes that users check and uncheck whenever they want and results differ based on that.

What I've tried so far:
I've made a profile tab with user form, including the fields, but the "edit user" form and it's not storing data.
I've changed the "city" field from select to checkbox and that crashed my form, since the field is included as non-toolset post select field.
I tried making the search results conditional, but I don't have stored data to include.

#2706783

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please explain with example and where you want to display what based on what field and where you added the user form or edit user form.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2707188

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I have a field "city" and taxonomy "listing categories", both made from other plugin.
==>
Can you please clarify where I can see those fields in backend and what plugin created those fields?

#2707201

The plugin is "TBC Data Parser".
hidden link

#2707203

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you be kind that you can share as much details as you can so it can help us to see the issue as well as help that shared details to investigate issue further.

I asked where I can see those field - "city" and "listing categories"?
- I have a field "city" and taxonomy "listing categories", both made from other plugin.

What are the possible values for the "city" and "listing categories"?

#2707245

Hi,
As far as I know, the plugin was created to put data from database of properties into the website - listings.
The fields we need to be seen on front end are: title, description, region(city),category,date of listing and images if any.
I'm not adequate, since I'm not involved into the plugin, but this is what i know.

The values for the "city":
Благоевград, Бургас, Варна, Велико Търново, Видин, Враца, Габрово, Добрич, Кърджали, Кюстендил, Ловеч, Монтана, Пазарджик, Перник, Плевен, Пловдив, Разград, Русе, Силистра, Сливен, Смолян, Софийска , София, Стара Загора, Търговище, Хасково, Шумен and Ямбол.
Values for "listing categories":Други движими вещи,Машини и съоръжения,Недвижими имоти and Превозни средства.

I've sent where the plugin is located, but I do not know where the fields are.

I can send requests to the plugin, but I need to know what to ask.

#2707247

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The fields we need to be seen on front end are: title, description, region(city),category,date of listing and images if any.
===========>
Well - when I checked the specific listing post in admin on edit screen:
- hidden link

I can see the "city" field - do you want to target that field?
- If yes, do you mean you want to store that city field as user custom "city" field?

I can also see the taxonomy listing category on right sidebar - do you want to target that?
- If yes, you can not assign taxonomy to users, so how you want to store the taxonomy? do you want to convert existing taxonomy terms to custom user select field?

- With date field, do you mean the "tender_date" that I can see with the above edit listing post page?

What about title, description, category, date of listing and image? from where to get those fields and see information about those fields?

In addition to that - I must acknowledge here this is custom code and debugging third party plugin is beyond the scope of our support policy. I hope this is understandable as we can not dive-in and explore how third-party custom field data is stored and managed.

#2707264

I need to target only these two - city and listing category. No other field.

- If yes, do you mean you want to store that city field as user custom "city" field? > yes, that is linked to listings and once chosen from user, the search view will change based on that.

- If yes, you can not assign taxonomy to users, so how you want to store the taxonomy? do you want to convert existing taxonomy terms to custom user select field? > This might be the best option and as above once chosen from user, search results vary based on them.

I've already used both fields in my search - as search parameters and they work great.

I understand for debugging the plugin.

#2707551

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've created the following view that will get all the terms of taxonomy listing categories:
- hidden link

And in backend admin on form edit page, I've changed the generic field that displays the listing categories as given under - this will help you to dynamically populate the listing categories terms as generic select options.

[cred_generic_field type='select' field='listing_category' class="" urlparam=""]
          {
"required":1,
"persist":1,
"default":[77],
"options":[ [wpv-view name="get-all-listing-category-terms"] ]
}
[/cred_generic_field]

Can you please share frontend user access details where user should access the form:
- hidden link

Also, do once user save his preference for city and listing category, when that user is logged-in and access the search page:
- hidden link

Do you want to pre-filter the view result with the value saved to "city" and "listing_category" of user custom field?

#2707762

This is the form > hidden link

Do you want to pre-filter the view result with the value saved to "city" and "listing_category" of user custom field? > Yes

#2707781

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share frontend user access details against what frontend user I should test the pre-filtering the result based on the set value using the form hidden link for the user city and listing category field.

Another question, if you want to prefilter the results based on user's selected city and listing category user fields, do you still want the custom search frontend filter's with the view, as when you prefilter the result it will only show to options for selected city and listing category. Do you want to display all options or remove search filters from your view or how you want it should work?

#2707963

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now: hidden link

I've added the following view's filter hook to "Custom Code" section offered by Toolset:
=> hidden link

add_filter('wpv_filter_query', 'func_user_selected_city_listing_cat', 99, 3);
function func_user_selected_city_listing_cat($query_args, $setting,$view_id) {
  
  		if($view_id == 9980 and is_user_logged_in() and pms_is_member() ) {
          
          		global $current_user;
                $user_id = $current_user->ID;
                
				$user_city = get_user_meta($user_id,'city',true);
                $user_listing_category = get_user_meta($user_id,'listing_category',true);
          
               
          		if($user_city) {
                  	 $query_args['meta_query'][] = array('key'=>'city',
                                              'value'=>$user_city,
                                              'type'=>'CHAR',
                                              'compare'=> '=');
                  
                } else if($user_listing_category) {
                  
                  	$query_args['tax_query'][] = array(
                                                'taxonomy'=> 'listing_category',
                                                'field' => 'id',
                                                'terms' => $user_listing_category,
                                                'operator' => 'IN');
                }
		}  
  
    return $query_args;
}

Can you please confirm it works as expected and shows results based on the selected city and listing category of user.

#2708717

Hi,
It's working. The listings show up after I "save" the user form in tab preference, but once I return to it again - it's reset.
I select option A, I go to search results, return to the tab and my selection in gone.
The search selection shows up, even if the user form no longer is selected correctly(reset on the tab preference).

#2708729

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

That is different thing.

I urge you to open a new ticket with every new question you may have. This will help other user's searching on the forum as well as help us to write correct problem resolution summery.

I split the ticket with your new question and will follow-up there:
- https://toolset.com/forums/topic/split-user-stored-preference-data-changes-search-results-generic-field-default-value-edit-form/

You are welcome to mark resolve this ticket.

#2708870

Thank you!