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

restricting results

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #33404
    historiento81historiento81
    Participant

    how can i restrict search results? your product is not complying with s2member restrictions.

    thanks

    R

    #33405
    historiento81historiento81
    Participant

    You cannot access this content.

    #33424
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    Does the s2member plugin has an api? That code looks all right to me, but I assume the current_user_can function does not work with the s2member plugin.
    There is probably a different function to check if the current user can access the post by ID.

    #33429
    historiento81historiento81
    Participant

    You cannot access this content.

    #33437
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    I understand that, but each plugin works differently. I am not the developer of S2Members plugin, I don’t know how it hooks into different functions of the WordPress core.
    It is impossible for us to test our plugins against all of the major plugins out there, but of course everyone tries to make everything work together and making compatible.

    To make it work the first step is to get to the S2Members api to find an internal S2Member plugin function – and I am sure there is one – which we can substitute into the code you mentioned above. Then simply change that one line where the role check is executed:

    !current_user_can(‘read_post’, $r->id)

    I am more than happy to help with the integration for a 3rd party plugin, even though it is not part of our support duties. If you know of any developer documentation, API or knowledge base links for that plugin, please feel free to share with us.

    The closest I could find is this one. However I don’t know if that works in the ajax context, but worth a try:

    add_filter( 'asp_results', 'asp_filter_posts_by_capability', 10, 1 );
    function asp_filter_posts_by_capability( $results ) {
    	foreach ($results as $k => &$r ) {
    	if ( !is_permitted_by_s2member($r->id) )
    		unset($results[$k]);
    	}
    	return $results;
    }
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.