Searching by custom posts not restricted by user

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Searching by custom posts not restricted by user

This topic contains 4 replies, has 2 voices, and was last updated by Stephenburke Stephenburke 7 years, 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #11131
    Stephenburke
    Stephenburke
    Participant

    Hi guys,

    The search bar won’t filter by registered courses for that user.

    An example of a user who had no courses setup against them is brendankearns, password cbe71755$$ but they can search for all custom posts.

    Regards,
    Steve.

    #11154
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Steve,

    I’ve looked up the LMS plugin code, and I have found a possible solution. I’ve made a minor modification to the initial custom code, for future reference it is now:

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

    I have found that the “sfwd_lms_has_access” function should always return if the user has access to the particular object (lesson, topic, quiz etc..). So I changed the code according to that.

    From my initial tests this appears to be working, but of course let me know if you find anything.

    I’ve also increased the results limit to 25 from the initial 10, because in cases where the results pool is greater than the limit and none of the courses are accessible to the user from that pool, he might not get any results at all, because the results are removed after the search, during the post process.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #11155
    Stephenburke
    Stephenburke
    Participant

    Wow,

    This is brilliant. Thanks.

    Great plugin, great support.

    #11156
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #11157
    Stephenburke
    Stephenburke
    Participant

    Done, Thanks Ernest.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Searching by custom posts not restricted by user’ is closed to new replies.