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

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

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #11131
    StephenburkeStephenburke
    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 MarcinkoErnest 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:

    [php]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;
    }[/php]

    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.

    #11155
    StephenburkeStephenburke
    Participant

    Wow,

    This is brilliant. Thanks.

    Great plugin, great support.

    #11156
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

    #11157
    StephenburkeStephenburke
    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.