• Resolved craigmckee

    (@craigmckee)


    I tried this code to append my users school name to the query and the ai just said “There has been a critical error on your website” so it looks like that didn’t work!

    // Add a filter to modify the AI query
    add_filter('mwai_ai_query', 'modify_mwai_query_with_school_name');
    
    function modify_mwai_query_with_school_name($query) {
        // Get the current user's ID
        $current_user_id = get_current_user_id();
    
        // Get the school_name attribute of the current user
        $school_name = get_user_meta($current_user_id, 'school_name', true);
    
        // Append or modify the query to include the school name
        // You might adjust this depending on the original query and desired format
        $query = $query . ' at ' . $school_name;
    
        return $query;
    }
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Val Meow

    (@valwa)

    Hey @craigmckee !

    This means there is an error either in your code or elsewhere. Please check your PHP logs, as the explanation should be found there.

    When using the mwai_ai_query filter, please use both arguments like: my_mwai_reply($reply, $query). Then you can modify the query’s reply like so:

    $reply->setReply($reply->result . " at " . $school_name);

    Hope this helps ??

    Thread Starter craigmckee

    (@craigmckee)

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pull User Meta’ is closed to new replies.