• PG

    (@parulgarg2)


    Hi

    The plugin is showing CPT in search result that is set to private.
    If you see the page, Pleo is set to private, but it is still showing up to the public. As soon as I deactivate Relevanssi, Pleo addon is no longer shown.

    Can you please help ?

    Thanks

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mikko Saari

    (@msaari)

    How is it set to private? Relevanssi should only show posts in results to users who are allowed to see them, but Relevanssi does not understand all methods of making a post private, and sometimes needs a little help.

    Who should see the “addon” CPT posts?

    Thread Starter PG

    (@parulgarg2)

    “addon” cpt is just like posts. they can be seen in public if published publically.

    I am also using ajax search pro plugin. When you search for “pleo” without pressing enter, then ajax search only shows 1 addon. but as i press enter shows result from relevanssi plugin and showing 2 addons out of which 1 is private.

    Plugin Author Mikko Saari

    (@msaari)

    So they’re just made private with the normal WP privacy controls? Relevanssi should respect that automatically. If that does not happen, something else is interfering with this.

    For private posts in custom post types, Relevanssi checks the capability for reading private posts in the CPT from $GLOBALS['wp_post_types'][ 'addon' ]->cap->read_private_posts. If nothing is defined there, Relevanssi tries read_private_addons. Relevanssi should only show the posts to users with that capability.

    That process is failing for some reason.

    Here’s one fix:

    add_filter( 'relevanssi_post_ok', function( $post_ok, $post_id ) {
      $status = relevanssi_get_post_status( $post_id );
      if ( 'private' === $status && ! is_user_logged_in() ) {
        $post_ok = false;
      }
      return $post_ok;
    }, 11, 2 );

    This should make private posts disappear from the search results for all users that are not logged in.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Private CPT showing in search result’ is closed to new replies.