Dynamic View Filtering from Create Post - Looking for a solution

By: Raul Diego | Asked: 09/24/2024
ForumsCategory: Code HelpDynamic View Filtering from Create Post - Looking for a solution
Raul Diego asked 3 months ago
I have a form set for creating posts and I am trying to find a way to filter the view by user, but not through the 'current_user' method, since the posts created must be visible pubicly. However, I am having trouble figuring out how to make sure that the unique path for the created posts loads the latest content created by a particular user and not just the latest form entries. I am looking these hooks for a possible solution: frm_after_create_entry frm_filter_where_val frm_where_filter Any help on this would be greatly appreciated.
3 Answers
Victor Font answered 3 months ago
If you want to filter by user, you have to use some data element tied to a user's WordPress record. Since you don't want to use current_user, you have to provide a way for a user to enter a user to filter your view. The frm_after_create_entry action has nothing to do with views.
Raul Diego answered 3 months ago
Thanks Victor.  Yes, that is the pickle I'm in. The general public that will be viewing the created posts will not be activiely filtering the view by interacting with a form or anything, so I am trying to see if there is a way to use a query in the url to pass a value dynamically to a filter hook in WP Code or something like that to make sure that the correct entries are displayed on the front end.  I have been looking into other ways I might possibly achieve my end goal without relying on filters at all. There is a script that uses the 'frm_after_create_entry' hook to break the View and Post connection after a post is created via a form, which may take care of the unique content side of this, but then I lose the ability to update the post via the original post creation form, which also needs to be a feature.  Another way may revolve around using the 'frm_after_create_entry' hook to delete all entries but keep the created post. This would preserve the form's updating capabilities, but would not save the user's previous entries, which introduces another set of problems. In any case, thanks again for your reply. I'll see if I can find a solution.  
Victor Font replied 3 months ago

You can always pass a value in a query string like this: my_url.com?param=value. Then you use [get param="param"] as your view filter. As an FYI, views have nothing to do with posts. Posts are filtered by wp_query. View are for Formidable entries.

This supports the "single-source-of-truth" principle in data management, when I create posts I no longer add data to them. I have a custom CPT template that displays a Formidable view in the post.

Raul Diego answered 3 months ago
So, turns out I didn't need to do anything. I guess the SSOT structure keeps the posts properly linked to the right content by default. Thanks for your help.

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