Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › ERROR AjaxSearchPro: include post_user_filter not working
This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko 3 years, 1 month ago.
- AuthorPosts
- November 2, 2020 at 9:08 am #30085
Hi support,
We added a short piece of code to include an argument on the post_user_filter arg.
We used the asp_query_args_change hook. Which works perfectly, except for author names with a (‘) up-comma in their name.If the author has this comma in their names, the error_log shows me that the mysql query cannot execute because of a typo.
Somewhere in your plugin needs to be a “Add slashes” function to be added (I think).
Can you look at this problem, please look at my ZIP file below.
Attachments:
You must be logged in to view attached files.November 2, 2020 at 9:21 am #30087Hi,
Thanks for the details!
The issue is not escaping, the plugin does not check for names, but user IDs. The issue is within the custom code, as it basically removes the ‘include’ sub-array argument, which causes an empty query part.
Try using this method instead to push the additional user ID there:
Best,$args['post_user_filter']['exclude'][] = $awuser[0]->data->id; $args['post_user_filter']['exclude'] = array_unique($args['post_user_filter']['exclude']);
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
November 2, 2020 at 9:33 am #30088Hi,
Thanks for the quick response.
I am not trying to exclude this ID, I want to include only that ID.
I tried the code above but it didn’t work for me. My original code did work. But not with the usernames with a (‘) quote in it.
I saw that we used the ID to filter but anywhere in the code it turns into a author name, and then a query breaks 🙁 (See zip 1)I will send another new zip. With my new information, to explain it a bit future.
Attachments:
You must be logged in to view attached files.November 2, 2020 at 9:46 am #30090Hi,
The $args[‘post_user_filter’] filter is to be used with user ID’s, and not user names. The argument is passed on to the query to check the wp_posts.post_author field, which is the user ID and not the user name.
If you passed on a user name there, it may seem to work, as the query was comparing user author names against a number ID field – but it never matched.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.