This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Restrict search results according to the user permissions

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Restrict search results according to the user permissions

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #26576
    fmislin80fmislin80
    Participant

    Hello,

    I just purchased Ajax Search Pro and love it, but could not find anywhere how to restrict the search results according to the logged in user permissions.

    My site is a conected only website and all the users have to login before accessing the content.

    I do not want an user to see search results showing them content they are not allowed to see even if they cannot access it.

    Thank you for your help.

    Best regards,

    Francis

    #26578
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    Thank you very much for your kind words!

    There is no such option on the back-end, as there is no such feature in WordPress by default.
    Do you use some sort of plugin to restrict content? If so, let me know if they have an API, as this is probably only solvable by custom coding.

    #26579
    fmislin80fmislin80
    Participant

    You cannot access this content.

    #26583
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi Francis,

    We can’t do paid support or custom work, but I found an older thread where something similar was resolved.

    Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

    add_filter( 'asp_results', 'asp_filter_posts_by_capability', 10, 1 );
    function asp_filter_posts_by_capability( $results ) {
    	foreach ($results as $k => &$r ) {
    		if ( isset($r->post_type) && !sfwd_lms_has_access($r->id) )
    			unset($results[$k]);
    	}
    	return $results;
    }
    #26596
    fmislin80fmislin80
    Participant

    Hello,
    Thank you so much !
    It works fine!
    And congratulations for making such a great plugin.
    Best regard,
    Francis

    #26598
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Restrict search results according to the user permissions’ is closed to new replies.