Meta Values

This topic contains 7 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 6 years, 11 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #12861
    jamigra
    jamigra
    Participant

    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

    #12879
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #12884
    jamigra
    jamigra
    Participant

    Hi 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

    #12888
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    I will definitely be able to advise, but it depends on how to get those values 🙂
    Let me know!

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #12893
    jamigra
    jamigra
    Participant

    Hi 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

    #12897
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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:

    get_option_display_value($user_id, 'peepso_user_field_3197', 'option_3197_2'); // returns 'Afghanistan'

    Or simply just something that translates the option into the value, like:

    get_display_value('option_3197_2');

    If any similar function/class method exists, then let me know.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #12909
    jamigra
    jamigra
    Participant

    Hi 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 6 years, 11 months ago by jamigra jamigra.
    Attachments:
    You must be logged in to view attached files.
    #12925
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    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:

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.