I am trying to call one of the built in functions within a custom php function but it isn’t working, I am assume I need to somehow declare this function as global but I’m not really sure what I am doing.
what I want to do is query one of the tables in the wordpress database and create a csv file that the user can download.
I have come up with this code:
$file = "Export.csv";
$fh=fopen($file,"w+") or die ("unable to open file");
$query = "select * from " . $wpdb->prefix . "newsletter";
$recipients = $wpdb->get_results($query . " order by email");