Custom search criteria – Filter by Field Values

Custom search criteria – Filter by Field Values

After an interesting question from academicdigital on the wordpress.org support forum, i would like to show now how to filter results by field values.

Show results of field number “2”, but only for users that have answered “10” to field number “3”

[gfchartsreports color_rand="true" include="2" chart_js_options="title: {display: true, text: 'Filtered: have answered 10 to question of field 3'}" custom_search_criteria='{"status":"active","field_filters":{"0":{"key":"3","value":"10"}}}' float="true" type="doughnut" height="400px" ][gfchartsreports color_rand="true" chart_js_options="title: {display: true, text: 'NOT Filtered: all answers'}" include="2" float="true" type="doughnut" height="400px" ]


About The Author

Comments (15)

  • Tunox

    Hello,
    In the above example shortcode how do we target the wanted form? Adding formid=”12″ doesn’t solve anything. The shortcode still goes looking for the custom search criteria on the first form created formid=”1″ (in my case the contact form). Obviouly this throws a “No answer to form Contact (1) yet” error.

  • June

    Hi,

    I have a question here, how do we set AND condition logic in the above example? I have tried to filter my entries as the following but the result is not specified to the condition I want:

    [gfchartsreports color_rand="true" include="1" custom_search_criteria='{"status":"active","field_filters":{"0":{"key":"2","value":"Project A","key":"3","value":"Female"}}}' float="true" type="pie" height="450px" ]

    where field 1 is Property Type, field 2 is Project Name, field 3 is Gender.

    I would like to show results of Property Type but only for users that have answered Project A to field number 2 AND Female to field number 3

    Any idea for this?

  • June

    Exactly ! Thank you very much!

  • izadpanah

    hi
    i used this shortcode
    [gfchartsreports gf_form_id="4" include="139" type="bar" color_set="blue" color_rand="0" height="400" tooltip_style="BOTH" position="center" custom_search_criteria="{"status":"active","field_filters":{"mode":"any","0":{"key":"173","value":"7"}}}" case_insensitive="0" filter="0"/]
    but custom_search_criteria does not work and it shows all my data
    what should i do?

    • MaxiCharts

      Hi!
      You criteria is not well formatted.
      Please use ‘ instead of “ around the whole parameter value, and remove the mode:any item.

      • izadpanah

        thanks but i didn’t work
        you mean this?
        [gfchartsreports gf_form_id="4" include="139" type="bar" color_set="blue" color_rand="0" height="400" tooltip_style="BOTH" position="center" custom_search_criteria="{"field_filters":{"0":{'key':'173','value':'7'}}}" case_insensitive="0" filter="0"/]
        would you please edit it for me?

        • MaxiCharts

          Again, simple quote and double quotes are misplaced, please look at example : custom_search_criteria='{“status”:”active”,”field_filters”:{“0”:{“key”:”3″,”value”:”10″}}}’

          Simple quote around the whole parameter value, and only double quotes inside.

        • MaxiCharts

          So, in your case, something like this:

          [gfchartsreports gf_form_id="4" include="139" type="bar" color_set="blue" color_rand="0" height="400" tooltip_style="BOTH" position="center" custom_search_criteria='{"field_filters":{"0":{"key":"173","value":"7"}}}' case_insensitive="0" filter="0"/]

          • izadpanah

            sorry but the out put is :
            No answer to form فرم پذیرش شتابدهنده (4) yet
            i have these plugins
            MaxiCharts
            MaxiCharts Gravity Forms Source Add-on
            MaxiCharts Gravity View Add-on
            MaxiCharts Query Builder Add-on
            what should i do? 🙁

        • MaxiCharts

          Please use the contact form to send you log file under maxicharts/logs/yyyy-mm-dd.log, right after your test.

Leave Comment