CaPa Protect
CaPa issue with search.. (2 posts)

  1. Freediver72
    Posted 4 years ago #

    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.


  2. daphatmac
    Posted 4 years ago #

    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;

    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 :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • CaPa Protect
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic