Custom Query returns array, but I can’t see it’s elements
Question
guys! I have the following problem to solve – I am using Private Content plugin which divides users into categories. I need to show all posts from the category that the author is part of. I tried adding a custom query, which as tested returns the proper count of rows that are affected, but I can’t get it to show the elements of the array (I have declared global $wpdb):
if (!current_user_can('administrator')) {
//$groupcat is something like this string 'a:1:{i:0;s:2:"23";}';
$groupcat = $wpdb->get_results( "SELECT `categories` FROM 7NIaM6l_pc_users WHERE `wp_user_id` = 13", ARRAY_N);
//Here I count the results and display them in the browser's console for check, which works fine
$ac = count($groupcat);
echo '<script>console.log("count ' . $ac . ' ")</script>';
//This part doesn't work.
echo '<script>console.log("First element: ' . groupcat[0] . ' ")</script>';
0
query, wpdb
4 years
2019-11-04T05:46:03-05:00
2019-11-04T05:46:03-05:00 0 Answers
47 views
0
Leave an answer