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 contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 1 year, 9 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #30085
    allroundweb03
    allroundweb03
    Participant

    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.
    #30087
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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']);
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #30088
    allroundweb03
    allroundweb03
    Participant

    Hi,

    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.
    #30090
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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 :)


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.