Hi Trevor,
thanks for pointing me to Edit Query Arguments Filter, must have missed that!
Here is how I set things up:
– a front end form for submitting private custom posts (cpt supports author)
– search & filter restricted to
– post type: my custom post type
– post status: private
I expected search & filter to take into account that limitation to private actually limits search results to current users posts, as a regular wordpress query would do. But maybe my setup is wrong.
If s&f doesn’t work this way, consider this a feature request. Because otherwise it renders wordpress post status private useless.
Next, I tried your approach of editing Arguments Filter, but it gives me no results. Probably wrong syntax?
function filter_user_posts( $query_args, $sfid ) {
$user_id = get_current_user_id();
//if search form ID = 109, do something with this query
if($sfid==109)
{
//modify $query_args here before returning it
$query_args = array(
'author' => $user_id
);
}
return $query_args;
}
add_filter( 'sf_edit_query_args', 'filter_user_posts', 20, 2 );
Speaking of security issues: I will further investigate the URL-snooping issue. But I also have a content restrictions on single post view in other places, so posts can’t be viewed by non-authors anyway.
Cheers,
Georg