Is it possible to utilize user meta fields to filter chart data?

By: Dan Zahlis | Asked: 06/15/2022
ForumsCategory: How-toIs it possible to utilize user meta fields to filter chart data?
Dan ZahlisDan Zahlis asked 2 years ago
We are trying to create a mental health referral system that is accessed by school district administrators, school site personnel and mental health service providers. We want all of the data collected to reside in a single table and filter the data views by District, School Site, Therapist and/or UserID. I used Pods to add meta fields to the User profile. I am filtering the table views using (for instance) "District is equal to [user_meta key=user_district]." It works perfectly. I want to filter the data used to generate charts in the same way. Is there a way to filter chart data with User meta fields?  
3 Answers
Bobby Clapp answered 2 years ago
Look here to start -> https://formidableforms.com/knowledgebase/graphs/#kb-filtering-parameters This is a list of parameters that the charts take as is.
Dan ZahlisDan Zahlis replied 2 years ago

Thanks, Bobby. I studied the parameters provided by that link to begin my quest. I didn't see a way to filter chart data using custom user meta fields. Did I miss something?

I didn't see any reference to charts, but could the code snippet suggested in this tutorial solve the problem?

https://connect.formidableforms.com/user-tutorials/display-content-based-on-user-meta-value/

Bobby Clapp replied 2 years ago

Good point. So you want to show data specific to a user with a particular meta field value then or are these graphs to be visible to the currently logged in user with a particular meta field value?

Dan ZahlisDan Zahlis replied 2 years ago

We want to show data specific to a user with a particular meta field value.

For instance, we want to limit the graph data to records where the "District" form field matches the user meta field "user_district". We do not want a school site person to see data (table or chart) across an entire district. For school site personnel, we would display chart data where the "School Site" form field is equal to the user meta field user_school_site.

Victor Font answered 2 years ago
You can probably do this with ChartJS. It's a lot more flexible than using Google Charts as Formidable does. https://www.chartjs.org/
Dan ZahlisDan Zahlis replied 2 years ago

Thanks, Victor. I'll give it a whirl!

Dan ZahlisDan Zahlis replied 2 years ago

I'm pretty sure I figured it out. It seems to be as easy as:

[frm-graph fields="xxx" type="column" data_type="count"][user_meta key=user_school_site][/frm-graph]

[frm-graph fields="xxx" type="column" data_type="count"][user_meta key=user_district][/frm-graph]

It would be nice to automagically inherit a view filter by clicking a box but this isn't too cumbersome.

Dan ZahlisDan Zahlis replied 2 years ago

Um. Never mind. It does NOT seem to be working. Ugh!

Shawn Pery answered 2 years ago
If it's a new form, you can save the meta value in a hidden field and filter that field.
Dan ZahlisDan Zahlis replied 2 years ago

Thanks, Shawn. I am saving the meta value in a hidden field within the form but I can't see how that allows me to filter a chart. I have no problems filtering data views using the custom user meta fields. I just can't find a way to apply a custom user meta field to filter a chart.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right