Home › Forums › Front-end Issues › Filtering data based on user id › Reply To: Filtering data based on user id
Replying to the first comment. I’m just another user. ACF is a very powerful tool, but one of the things that make it powerful is that the scope of the plugin is kept very specific. An admin that allows easy management of custom data. It also contains a large number of filters and actions that can be used to customize it to almost anything we can think of. There is nothing in it that will help us use that data to manage how content is displayed on the front end. Most of my suggestions in my first reply are using the tool, filters and actions built in to both ACF and WP.
On you follow up question, I’m not exactly sure what you mean by dashboard. If you are referring to the list of posts admin page, this can also be done.
The reason that I suggested the preparing of data in the database only has to do with making queries for WP_Query() or filtering of posts both easier to construct and faster to perform and is is based what type of field that is being used. In the example, a user field can be queried directly, and yes, you can do what I suggested without it, but it requires doing a “LIKE” query on the user field. The different ways to construct a query is covered here https://www.advancedcustomfields.com/resources/query-posts-custom-fields/. The main difference is that a filter on a field using the =
comparison is much faster than a LIKE
query and one I always keep one eye on performance when I’m deciding on a solution. In your case, you could likely get away with the “LIKE” query because you’ll only be filtering by a single user. These like queries can get out of hand more quickly if you attempt to filter by multiple values at the same time.
Anyway the same type of filtering can be done in the admin to show a logged in user only a list of their own posts for a post type. However, I would be careful here as this would also limit your ability to see them. You would want to check the user type rather than a specific user or not filter posts for a specific user ID, like your own.
I rarely find an out of the box solution for most of the things that I need to do, and when I do those solutions are usually overkill, including features that will never be used and only server to complicate the admin 😛
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.