Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

OK, so I can restrict the posts visible to Authors within the admin using the following code:

function MY_FUNCTION( $wp_query ) {
     if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
          global $current_user;
          $wp_query->set( 'author', $current_user->id );
     }
}
add_filter( 'parse_query', 'MY_FUNCTION' );

What I'm trying to achieve:

I'm building a supplier website, where I have both Normal Users and some users that become Approved Suppliers (AS) - These AS have a Profile Page - a Custom Post Type (CPT) with a unique Approved Supplier ID - via Advanced Custom Fields (ACF).

Example of ASID = AS1310P123456

Every post that a AS writes has their ASID saved to the post's postmeta.

So, I'm would like to use the ASID (AS1310P123456) when running the $wp_query.

Something like this:

function MY_FUNCTION( $wp_query ) {
     if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
          $wp_query ->WHERE ASID IS IN THE POSTMETA
     }
}
add_filter( 'parse_query', 'MY_FUNCTION' );

I'm really struggling with this one, so any help greatly appreciated, Ian.

share|improve this question
1  
And a meta_query doesn't work? –  s_ha_dum Oct 18 '13 at 13:57
    
It could do, but I clearly don't know how to use meta_query (sorry, I'm new to wp backend dev). Thanks anyway ;o( –  Ian Oct 18 '13 at 15:37
    
That was a gentle way of saying that you are expected to have researched the problem and made an attempt at solving it before posting. This is not a "do my homework for me" forum. There are numerous examples of using a meta_query on this site and in the Codex. I provided a link to some of those. Read through them. Try something. –  s_ha_dum Oct 18 '13 at 15:45
    
Hey, I really do appreciate your help and I'm trying to find the solution - you'll laugh, but I've been stuck with this for nearly 3 days solid now and I'm only posting here as a last resort, so I'm not expecting you do do my homework for me, I was genuinely looking for help. –  Ian Oct 18 '13 at 15:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.