Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Groups and hide products
- This topic has 6 replies, 2 voices, and was last updated 7 years, 3 months ago by
Ernest Marcinko.
-
AuthorPosts
-
February 20, 2019 at 1:36 pm #21196
Optec
Participanthi 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:
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!
February 20, 2019 at 1:51 pm #21199Ernest Marcinko
KeymasterHi!
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.
February 20, 2019 at 1:52 pm #21200Optec
ParticipantYou cannot access this content.
February 20, 2019 at 1:57 pm #21201Optec
ParticipantYou cannot access this content.
February 20, 2019 at 2:37 pm #21202Ernest Marcinko
KeymasterHi,
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!
February 20, 2019 at 2:38 pm #21203Optec
ParticipantI literally just logged on to test something and saw it was working!
You sir are a genius 🙂
February 20, 2019 at 2:40 pm #21204Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- You must be logged in to reply to this topic.