PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Limit Query based on User Information

  1. I've hacked the GF CPT plugin to display posts (instead of taxonomies) in the dropdown so I can save a post 2 post relation. The data set I'm dealing with is huge (will be 20,000 plus items - all schools in the US) so I'd like to limit things.

    My first thought is to get the state of the current user (which we collected earlier on the site in a custom profile field) but it seems that $current_user isn't available when we populate the field in the code below.

    https://gist.github.com/1182856

    Limiting the query manually by state works fine (as in I just type the meta_key and meta_value in). Anyone know how I can get the meta_value in to the function so I can limit the query to something reasonable?

    Posted 12 years ago on Wednesday August 31, 2011 | Permalink
  2. I just came up with something a bit hacky but it works. I'm setting a transient with the value on the form submission just before the one I need to filter. The transient is the data I need and is available early enough that I can use it in my query.

    Posted 12 years ago on Wednesday August 31, 2011 | Permalink