• Resolved RHP

    (@rhp)


    How can we edit this so it finds/searches for password protected pages?

    For example, if you’re a visitor and naturally logged in, but you have a password and need to find a page. If you use the search, you it won’t bring up that page/post/gallery at all.

    Is there a work around?

    p.s. I have to say, I’ve searched for quite a few similar plugins today, and tested many, and this is by far the most intuitive and easy to use one.

    https://www.ads-software.com/plugins/wp-extended-search/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Sumit Singh

    (@5um17)

    Hi,

    First a big thanks for your nice post script ??

    This is a missed functionality, I will add this to dev version as soon as I get time and later I will make it official.
    Will keep you posted.

    Thanks a lot!

    Thread Starter RHP

    (@rhp)

    Hi Sumit,

    Thank you for your reply! I appreciate you making the time.

    I’ve actually found a work around using a two different plugins. But if you update it, I’d be happy to support it, as yours is much more intuitive.

    Thread Starter RHP

    (@rhp)

    Hi Sumit,

    I just wanted to note the code that I added via a plugin called “My Custom Functions”. This, combined with the below code, allowed the searching of protected pages with wordpress, only your plugin seemed to conflict with this, so I had to use something else. I know zero about coding but thought I’d share this in case it’s useful.

    // include password protected pages in search results

    add_filter( ‘posts_search’, ‘include_password_posts_in_search’ );
    function include_password_posts_in_search( $search ) {
    global $wpdb;
    if( !is_user_logged_in() ) {
    $pattern = ” AND ({$wpdb->prefix}posts.post_password = ”)”;
    $search = str_replace( $pattern, ”, $search );
    }
    return $search;
    }

    Plugin Author Sumit Singh

    (@5um17)

    Hi,

    Sorry for the delayed reply!

    I am sorry I did not get your request at first. You want password protected pages to show up even when user is not logged-in then this code is fine just increase the priority of filter you are adding.
    I mean instead of this line


    add_filter( ‘posts_search’, ‘include_password_posts_in_search’ );

    use this


    add_filter( 'posts_search', 'include_password_posts_in_search', 501 );

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Search protected pages?’ is closed to new replies.