<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Notice: Trying to get property &#039;roles&#039; of non-object ERROR - How-to and Troubleshooting - wpForo 2.0				            </title>
            <link>https://wpforo.com/community/how-to-and-troubleshooting-2/notice-trying-to-get-property-roles-of-non-object-error/</link>
            <description>Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Sat, 09 May 2026 16:15:52 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Notice: Trying to get property &#039;roles&#039; of non-object ERROR</title>
                        <link>https://wpforo.com/community/how-to-and-troubleshooting-2/notice-trying-to-get-property-roles-of-non-object-error/#post-68313</link>
                        <pubDate>Sat, 06 Aug 2022 10:34:46 +0000</pubDate>
                        <description><![CDATA[@chris Yes after the update everything works amazingly. Thank you very much.]]></description>
                        <content:encoded><![CDATA[@chris Yes after the update everything works amazingly. Thank you very much.]]></content:encoded>
						                            <category domain="https://wpforo.com/community/how-to-and-troubleshooting-2/">How-to and Troubleshooting - wpForo 2.0</category>                        <dc:creator>bottas</dc:creator>
                        <guid isPermaLink="true">https://wpforo.com/community/how-to-and-troubleshooting-2/notice-trying-to-get-property-roles-of-non-object-error/#post-68313</guid>
                    </item>
				                    <item>
                        <title>RE: Notice: Trying to get property &#039;roles&#039; of non-object ERROR</title>
                        <link>https://wpforo.com/community/how-to-and-troubleshooting-2/notice-trying-to-get-property-roles-of-non-object-error/#post-68297</link>
                        <pubDate>Sat, 06 Aug 2022 09:03:10 +0000</pubDate>
                        <description><![CDATA[Hi @bottas,
Please update to 2.0.4 and delete all caches. This issue should already be fixed.]]></description>
                        <content:encoded><![CDATA[<p>Hi <span>@bottas,</span></p>
<p><span>Please update to 2.0.4 and delete all caches. This issue should already be fixed.</span></p>]]></content:encoded>
						                            <category domain="https://wpforo.com/community/how-to-and-troubleshooting-2/">How-to and Troubleshooting - wpForo 2.0</category>                        <dc:creator>Chris</dc:creator>
                        <guid isPermaLink="true">https://wpforo.com/community/how-to-and-troubleshooting-2/notice-trying-to-get-property-roles-of-non-object-error/#post-68297</guid>
                    </item>
				                    <item>
                        <title>RE: Notice: Trying to get property &#039;roles&#039; of non-object ERROR</title>
                        <link>https://wpforo.com/community/how-to-and-troubleshooting-2/notice-trying-to-get-property-roles-of-non-object-error/#post-68174</link>
                        <pubDate>Fri, 05 Aug 2022 10:23:41 +0000</pubDate>
                        <description><![CDATA[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).]]></description>
                        <content:encoded><![CDATA[<p>You should DISABLE debug issues to be displayed in the website. Enable them to debug.log.</p>
<p>About your issue, could be some conflict with an other plugin (a plugin that has to do with users).</p>]]></content:encoded>
						                            <category domain="https://wpforo.com/community/how-to-and-troubleshooting-2/">How-to and Troubleshooting - wpForo 2.0</category>                        <dc:creator>dimalifragis</dc:creator>
                        <guid isPermaLink="true">https://wpforo.com/community/how-to-and-troubleshooting-2/notice-trying-to-get-property-roles-of-non-object-error/#post-68174</guid>
                    </item>
				                    <item>
                        <title>Notice: Trying to get property &#039;roles&#039; of non-object ERROR</title>
                        <link>https://wpforo.com/community/how-to-and-troubleshooting-2/notice-trying-to-get-property-roles-of-non-object-error/#post-68160</link>
                        <pubDate>Fri, 05 Aug 2022 09:07:30 +0000</pubDate>
                        <description><![CDATA[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: &quot;Notice: Trying to g...]]></description>
                        <content:encoded><![CDATA[<p>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: "<strong>Notice</strong><span>: Trying to get property 'roles' of non-object in </span><strong>/var/www/vhosts/mydomain.com/httpdocs/wp-content/plugins/wpforo/includes/hooks.php</strong><span> on line </span><strong>22</strong>"</p>
<p>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?</p>
<pre contenteditable="false">ORIGINAL PIECE OF CODE:

add_action( 'show_admin_bar', function( $show_admin_bar ) {
	if( ! is_super_admin() &amp;&amp; is_user_logged_in() &amp;&amp; ! array_intersect( , (array) WPF()-&gt;wp_current_user-&gt;roles ) ) {
		$show_admin_bar = (bool) array_intersect( WPF()-&gt;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);
</pre>
<div id="wpfa-12413" class="wpforo-attached-file"><a class="wpforo-default-attachment" href="//wpforo.com/wp-content/uploads/wpforo/default_attachments/1659690450-Capture.png" target="_blank" title="Capture.PNG"><i class="fas fa-paperclip"></i>&nbsp;Capture.PNG</a></div>]]></content:encoded>
						                            <category domain="https://wpforo.com/community/how-to-and-troubleshooting-2/">How-to and Troubleshooting - wpForo 2.0</category>                        <dc:creator>bottas</dc:creator>
                        <guid isPermaLink="true">https://wpforo.com/community/how-to-and-troubleshooting-2/notice-trying-to-get-property-roles-of-non-object-error/#post-68160</guid>
                    </item>
							        </channel>
        </rss>
		