Notice: Undefined offset:
-
Hey Guys,
There’s a weird error popping up with the plugin. I’m using 4.0 with the Genesis framework. The error shows its ugly head when you click to see the full post from the blog page.
Below is the error.
Notice: Undefined offset: 0 in /home2/campane3/public_html/wp-content/plugins/post-views-stats/cn-post-views-stats.php on line 62
Line 62 refers to the function called “track_post_view”.
See below
function track_post_view() { global $post,$wpdb; if(is_single()) { $current_user = wp_get_current_user(); $user_role = $current_user->roles[0]; if ( $user_role != 'administrator' ) { $table_name = $wpdb->prefix . "cn_track_post"; $insert = "INSERT INTO " . $table_name . "( post_id, created_at, create_date ) VALUES (" . $post->ID . ",'" . time() . "','" . date('Y-m-d')."')"; $results = $wpdb->query( $insert ); if($results) $msg = "Updated"; } } }
Line 62 is….
$user_role = $current_user->roles[0];
What could the issue be? Is it me?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Notice: Undefined offset:’ is closed to new replies.