- This topic has 7 replies, 2 voices, and was last updated 7 years, 4 months ago by Ernest Marcinko.
-
AuthorPosts
-
April 25, 2017 at 11:11 pm #12861jamigraParticipant
Hi. I love the search, but I am having some issues.
I am using the ‘General Options>User Search’
My user meta field is ‘peepso_user_field_3197’ and it returns the results from the database fine.
The problem is that the results are in this format: option_3197_2, option_3197_3, option_3197_4 …
But actually I want the format to be readable: Afghanistan, Albania, Algeria, …
Is there an asp results filter function that I could set up to convert ‘option_3197_2’ to ‘Afghanistan’, convert ‘option_3197_3’ to ‘Albania’….and so on….
You can please see this link where some of the results are displayed http://comosaconnect.org/labs/
Thanks
April 26, 2017 at 11:24 am #12879Ernest MarcinkoKeymasterHi!
This could be possible, but I have to know either where or how the actual countries are stored, or preferably if there is any function/class that is used to translate the option values to country names. Maybe an internal function that expects the option value as the parameter and returns the country name, or a list of countries with the codes or anything like that.
If such thing exists, it should be possible relatively easile. Let me know anything you know about it, and I will try to help.
April 26, 2017 at 5:56 pm #12884jamigraParticipantHi Ernest
Good question. I am not sure where they are stored. I will ask the plugin developer.
If I can find the answer I was hoping you had an asp function that would allow me to define the alternative value and replace it. So replace option_3197_2 with Afghanistan.
Thanks
April 27, 2017 at 5:20 am #12888Ernest MarcinkoKeymasterHi,
I will definitely be able to advise, but it depends on how to get those values 🙂
Let me know!April 27, 2017 at 7:56 am #12893jamigraParticipantHi Ernest
I am told that the corresponding country names are stored in a different table in the data base and it is serialized…. “Extended profile value of is stored in postmeta table.
You can find it using SELECT * FROM wp_postmeta WHERE meta_key = ‘select_options’ AND post_id = [YOUR_POST_ID].
As a note, the data is in serialized format.”Can Ajax search handle serialized data? Or is the best option to have a function that does replacement in the search results…so replace “option_3197_2” with “Afghanistan”. Will I also then be able to search for “Afghanistan”?
Please let me know what could be a solution to this problem.
Thanks
April 27, 2017 at 3:06 pm #12897Ernest MarcinkoKeymasterHi,
Searching won’t be possible for sure, as the information is serialized. That is not possible to search with the MySQL database.
I understand the information, but it won’t help in your case. There must be some kind of function or a class function that can retrieve the option values based on the custom field name/value, something like:
[html]get_option_display_value($user_id, ‘peepso_user_field_3197’, ‘option_3197_2’); // returns ‘Afghanistan'[/html]
Or simply just something that translates the option into the value, like:
[php]get_display_value(‘option_3197_2’);[/php]
If any similar function/class method exists, then let me know.
April 28, 2017 at 7:27 pm #12909jamigraParticipantHi Ernest. They said to check _render_form_select function in peepso-core/classes/fields/fieldselectsingle.php.
I have attached the file. Is there an asp results function that can talk to this file or can extract the information from the serialised data?
Many thanks
- This reply was modified 7 years, 4 months ago by jamigra.
May 1, 2017 at 9:00 am #12925Ernest MarcinkoKeymasterHi!
That does look close to what we might need, but from what I can see, that function returns the select box output HTML code, not the values, and moreover it’s declared as ‘protected’ – therefore it cannot be accessed from outside the class. So even if it was correct, it’s not possible to use it.
I’m not sure what other functions there are available in that class, because it’s inherited from ‘PeepSoField’ parent class, and there are probably other functions inherited there as well.
This should not be this complicated, I’m almost certain there is a very simple way of getting the option display value from the option actual value.
Here is an example code I would use to get the values. This is not complete, as it’s missing the function to convert the option data to the country name based on meta:
-
AuthorPosts
- You must be logged in to reply to this topic.