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

Groups and hide products

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #21196
    OptecOptec
    Participant

    hi Ernest,

    Firstly – loving the plugin, it has unlocked so many more features than i had expected and I am spending WAY to long on getting the perfect search!! 🙂

    Question, I have tried the below and added the code to my functions.php on my child theme:

    https://wp-dreams.com/knowledge-base/restricting-results-by-user-groups-using-the-groups-plugin-by-itthinx/

    I see no change though and products keep popping up that shouldn’t.. The plugin is restricting access to theproducts as expected – I just need them to stop showing up unless part of the user group!

    #21199
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    Thank you for your kind words, I really appreciate them!

    I tried to log-in with the details, but it says, that the password is incorrect. Can you please check that? If you are using the Groups plugin, and it’s not working, then can you please also add temporary FTP access as well? I would like to debug through that custom code to see what exactly is happening there.

    #21200
    OptecOptec
    Participant

    You cannot access this content.

    #21201
    OptecOptec
    Participant

    You cannot access this content.

    #21202
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    Thank you very much!

    I think I managed to find a solution based on the plugin API. The category based exclusions seem to have a different API, so the code needs to be extended. The final solution is:

    add_filter('asp_results', 'asp_fix_groups_exclusions', 10, 1);
    function asp_fix_groups_exclusions($results) {
    	// Group based exclusions
    	if ( class_exists('Groups_Post_Access') ) {
    		foreach ($results as $k => &$r) {
    			if ( isset($r->post_type) && !Groups_Post_Access::user_can_read_post($r->id) )
    				unset($results[$k]);
    		}
    	}
    	// Category based exclusions
    	if ( class_exists('Groups_Restrict_Categories') ) {
    		foreach ($results as $k => &$r) {
    			if ( isset($r->post_type) && !Groups_Restrict_Categories::user_can_read($r->id) )
    				unset($results[$k]);
    		}
    	}
    	return $results;
    }

    Please check if this is correct. Thanks!

    #21203
    OptecOptec
    Participant

    I literally just logged on to test something and saw it was working!

    You sir are a genius 🙂

    #21204
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.