cguidog
Forum Replies Created
Viewing 3 replies - 1 through 3 (of 3 total)
-
@bcworkz I couldn’t get this to work even after disabling all plugins and using a default theme. I ended up finding an alternative non-ajax solution to my problem.
@bcworkz These are placeholder values. I wanted to test this way before passing the actual parameters; in reality the query will have several parameters.
I have two functions. This is the function that runs the query and it’s located in
functions.php
function export_users_function_test() { $args = array( 'number' => 10, 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'employee', 'value' => '1', 'compare' => '=' ), array( 'key' => 'gender', 'value' => 'female', 'compare' => '=' ), array( 'key' => 'member', 'value' => '1', 'compare' => '=' ) ) ); $user_query = new WP_User_Query( $args ); return $user_query; }
This is the function located in my
ajax
file, which calls the function infunctions.php
:public function export_users_function() { $params = $_POST['params'] ?: null; $query = export_users_function_test() ?: null; $users = $query ? $query->results : null; $header = '"Email",'; while(have_rows('file_columns', 'option') ): the_row(); $header .= '"' . get_sub_field('column_name') . '",'; endwhile; $header .= "\r\n"; if ($users) { foreach ($users as $user) { $header .= '"' . $user->user_email . '",'; while(have_rows('file_columns', 'option') ): the_row(); $header .= '"' . get_user_meta( $user->ID, get_sub_field('user_meta_key'), true) . '",'; endwhile; $header .= "\r\n"; } } echo wp_send_json($header); }
That answer is from ChatGPT, and it doesn’t solve the issue.
Viewing 3 replies - 1 through 3 (of 3 total)