Since the new update came out (WpForo 2), logged in users, except the admin, are presented with a really annoying banner on top of my website showing this error message: "Notice: Trying to get property 'roles' of non-object in /var/www/vhosts/mydomain.com/httpdocs/wp-content/plugins/wpforo/includes/hooks.php on line 22"
I already tried many things, I was able to temporarily fix it by changing this lines of code (22-27) in the hooks.php file. I copied this code from a really old post that I found in your support forum. But as I said this just temporary, every new update I need to manually change the code. Is there a way you can help me?
ORIGINAL PIECE OF CODE: add_action( 'show_admin_bar', function( $show_admin_bar ) { if( ! is_super_admin() && is_user_logged_in() && ! array_intersect( [ 'editor', 'administrator', 'author', ], (array) WPF()->wp_current_user->roles ) ) { $show_admin_bar = (bool) array_intersect( WPF()->current_user_groupids, wpforo_setting( 'general', 'admin_bar' ) ); } return $show_admin_bar; }); HOW I CHANGED IT: function my_admin_bar_control_function() { if (current_user_can('administrator') || current_user_can('editor') || current_user_can('author') ) { show_admin_bar(true); } else { show_admin_bar(false); } } add_action('init', 'my_admin_bar_control_function', 20);
You should DISABLE debug issues to be displayed in the website. Enable them to debug.log.
About your issue, could be some conflict with an other plugin (a plugin that has to do with users).
Hi @bottas,
Please update to 2.0.4 and delete all caches. This issue should already be fixed.