ERROR AjaxSearchPro: include post_user_filter not working
Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › ERROR AjaxSearchPro: include post_user_filter not working
- This topic has 3 replies, 2 voices, and was last updated 5 years, 8 months ago by
Ernest Marcinko.
-
AuthorPosts
-
November 2, 2020 at 9:08 am #30085
allroundweb03
ParticipantHi 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.
November 2, 2020 at 9:21 am #30087Ernest Marcinko
KeymasterHi,
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:
$args['post_user_filter']['exclude'][] = $awuser[0]->data->id; $args['post_user_filter']['exclude'] = array_unique($args['post_user_filter']['exclude']);November 2, 2020 at 9:33 am #30088allroundweb03
ParticipantHi,
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.
November 2, 2020 at 9:46 am #30090Ernest Marcinko
KeymasterHi,
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.
-
AuthorPosts
- You must be logged in to reply to this topic.