Support

Account

Home Forums Add-ons Repeater Field Comparing two fields from different users

Solving

Comparing two fields from different users

  • Hi. Is it possible to list all posts from others users that have the same field input as one of the logged in user’s? In other words, can a logged in user see other user’s specific related content (on the basis of a particular field)? What makes this a little more complicated is that one of the fields uses a repeater (with a number sub field) and the other one is just a number field.

    The context is this: (1) Members use the front-end of this website to log the release into the wild of endangered birds, with leg rings. Every release generates a custom post including a repeater field for the leg ring numbers. (2) When someone finds a dead bird with a leg ring they can also log it and it’s location on the website, which also generates a custom post. (3) The original member should then be notified that one of their released birds has been found.

    I think this must be possible but I’m struggling to put the pieces together. Any help would be very much appreciated.

  • Hi @langton82

    You can query posts based on the repeater field, but you need to create a custom filter to replace the standard query. This page should give you more idea about it (under the 4. Sub custom field values section): http://www.advancedcustomfields.com/resources/query-posts-custom-fields/.

    I hope this helps.

  • Thanks James. Can I ask a related question to see if there is a simpler way to solve the same problem?

    Is it possible to store the value of a particular custom field (for all applicable posts) as a variable that could then be used as the ‘value’ in a meta_query?

    In my context that would mean storing all ring numbers (from all users) as a variable to be compared to the released ring numbers of the signed-in user.

  • Hi @langton82

    To get the ring lists, you can always use wpdb class. This page should give you more idea about it: https://codex.wordpress.org/Class_Reference/wpdb.

    I hope this helps.

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

The topic ‘Comparing two fields from different users’ is closed to new replies.