Support » Plugin: CaPa Protect » [Plugin: CaPa Protect] CaPa issue with search..

  • CaPa works great. It hide all my posts in the categories I chose to hide. Then I added the search function. The search returns the posts that were hidden. The title does not show, bit the first three lines are in the results. If you click on the post to read the rest that is protected. So the issue is the search results showing the first three lines of private posts.

    http://wordpress.org/extend/plugins/capa/

Viewing 1 replies (of 1 total)
  • Hey Freediver,

    Not sure if this will help you, but I came across a similar issue – I thought about hacking the plugin, but I ended up using a custom query – here’s my code with a bit tacked on for pagination.

    //setup pagination
    $paged = 1;
    
    if(isset($_GET['paged'])) {
      if($_GET['paged'] != '') {
        $paged = $_GET['paged'];
      }
    }
    
    $args['paged'] = $paged;
    
    //get custom protection categories from CAPA
    $CAPA_settings = get_option('capa_protect_cat_user_'.$current_user->ID, ''); 		
    
    if(is_array($CAPA_settings)) {
    
      foreach($CAPA_settings as $category=>$value) {
        $allowed_categories[] = $category;
      }
    
      $args['category__in'] = $allowed_categories;	
    
    }
    
    //setup custom query
    $args['s'] = $search_term;
    
    query_posts($args);

    So I basically pull the CAPA defined permissions for the current user, based on their ID (if you get an error about the user ID, you may need to bring the $current_user variable into the page from the global scope by adding global $current_user; to the beginning of this snippet.

    This seems to work OK for me so far, and it might give you a headstart in the right direction 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: CaPa Protect] CaPa issue with search..’ is closed to new replies.