Limit posts by user_ids (but broken
-
I’ve modded the plugin to allow an extra argument of ‘user_id’ which can accept a comma delimited list of user_ids, which then get passed to the ‘get_posts’ call to limit the posts to those made by certain users.
This is useful for creating a page on an individual users personal network site, that collects together all the blog posts they’ve made across the entire network, on multiple collaborative network sites.
However the code appears to have broken pagination. Any solution would be appreciated.
The code is as follows:
Around line 310:
// Display user or users // if the user passes one value $user_ids = array(); if( !preg_match("/,/",$user_id) ) { // Always clean this stuff ;) (oh.. told you I'm a paranoid) $user_id = (int)htmlspecialchars($user_id); // Check if it's numeric if( is_numeric($user_id) ) { // and put the sql $user_ids[] = htmlspecialchars($user_id); } // if the user passes more than one value separated by commas } else { // create an array $temp_array = explode(",",$user_id); for( $counter=0; $counter < count($temp_array); $counter++){ $user_ids[] = (int)$temp_array[$counter]; } }
Around line 473;
`
// Author restriction?
if(!empty($user_ids)) {
$args[‘author’] = implode(‘,’,$user_ids);
}’I also added ‘user_id’ to the $defaults array.
- The topic ‘Limit posts by user_ids (but broken’ is closed to new replies.