User Tracking for Custom Post Type “Lesson”. Database Queries and Performance

Since there are going to be more than one post (lesson) per user, your code would be more like this: <?php if ( is_user_logged_in() ) { $user_ID = get_current_user_id(); $post_ID = get_the_ID(); $viewed = get_user_meta( $user_ID, ‘viewed_lesson_tracking’, true); if(empty($viewed)){ $viewed = array(); } $viewed[] = $post_ID add_user_meta( $user_ID, ‘viewed_lesson_tracking’, $viewed ); // tracks that user … Read more

Outputting query results

By default, wordpress get_results return a numerically array of objects, so to use echo to print your data yo should do something like; foreach($myrows as $line){ echo $line->question; }

No users table in WordPress’s database

Normally WordPress does not allow you to delete ‘super admin’ through its dashboard, all other users can be deleted. But in your case I think, its some one who deleted all users from the table directly by accessing your WordPress database via phpmyadmin or so. Even if there is no users in the site, the … Read more