Title: Pull User Meta
Last modified: September 25, 2023

---

# Pull User Meta

 *  Resolved [craigmckee](https://wordpress.org/support/users/craigmckee/)
 * (@craigmckee)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/pull-user-meta/)
 * 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!
 *     ```wp-block-code
       // 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](https://wordpress.org/support/users/valwa/)
 * (@valwa)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/pull-user-meta/#post-17084179)
 * Hey [@craigmckee](https://wordpress.org/support/users/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](https://wordpress.org/support/users/craigmckee/)
 * (@craigmckee)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/pull-user-meta/#post-17084983)
 * Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Pull User Meta’ is closed to new replies.

 * ![](https://ps.w.org/ai-engine/assets/icon-256x256.png?rev=3431928)
 * [AI Engine - The Chatbot, AI Framework & MCP for WordPress](https://wordpress.org/plugins/ai-engine/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ai-engine/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ai-engine/)
 * [Active Topics](https://wordpress.org/support/plugin/ai-engine/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ai-engine/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ai-engine/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [craigmckee](https://wordpress.org/support/users/craigmckee/)
 * Last activity: [2 years, 8 months ago](https://wordpress.org/support/topic/pull-user-meta/#post-17084983)
 * Status: resolved