<?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>
									function call to assign wpForo user role? - wpForo				            </title>
            <link>https://gvectors.com/forum/general-questions/function-call-to-assign-wpforo-user-role/</link>
            <description>WordPress Plugins Support Forum</description>
            <language>en-US</language>
            <lastBuildDate>Wed, 14 Oct 2026 07:29:45 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: function call to assign wpForo user role?</title>
                        <link>https://gvectors.com/forum/general-questions/function-call-to-assign-wpforo-user-role/#post-22298</link>
                        <pubDate>Tue, 21 Apr 2020 08:39:39 +0000</pubDate>
                        <description><![CDATA[Found the code in wpf-hooks.php line 2521  wpforo_update_usergroup_on_role_change
however, cannot call that function UNLESS the sync flag is turned on.
I guess, what I am looking for is an...]]></description>
                        <content:encoded><![CDATA[<p>Found the code in wpf-hooks.php line 2521  wpforo_update_usergroup_on_role_change</p>
<p>however, cannot call that function UNLESS the sync flag is turned on.</p>
<p>I guess, what I am looking for is an additional optional parameter on the end of the call:</p>
<p>$ignore_sync_flag = 0  (default)</p>
<p>pass in a zero, and it means "look at the sync flag feature setting"</p>
<p>pass in a one, and it means: "set the role regardless of the sync flag feature"</p>
<p>I think, that would make it much more usable, then I could turn off the forced sync feature, and call this function to change a users' wpForo user group.</p>
<p>Thoughts?  (i've pasted the updated code below that would make this work the way I describe)</p>
<pre>function wpforo_update_usergroup_on_role_change( $userid, $new_role, $old_roles = array() <strong>,$ignore_sync_flag=0</strong>){<br />    if( wpforo_feature('role-synch') <strong>|| $ignore_sync_flag==1</strong> ) {<br />        $user_ug_id =  WPF()-&gt;member-&gt;get_usergroup( $userid );<br />        $role_ug_ids = WPF()-&gt;usergroup-&gt;get_usergroups_by_role( $new_role );<br />        if( !empty($role_ug_ids) &amp;&amp; is_array($role_ug_ids) ){<br />            if( count($role_ug_ids) &gt; 1 ){<br />                $prime_ugid = array_shift($role_ug_ids);<br />                if( !in_array($user_ug_id, $role_ug_ids) ){<br />                    WPF()-&gt;member-&gt;set_usergroup( $userid, $prime_ugid );<br />                    WPF()-&gt;member-&gt;set_usergroups_secondary( $userid, $role_ug_ids );<br />                }<br />            }<br />            else{<br />                $groupid = current($role_ug_ids);<br />                if( $groupid != $user_ug_id ){<br />                    WPF()-&gt;member-&gt;set_usergroup( $userid, $groupid );<br />                }<br />            }<br />        }<br />    }<br />}</pre>]]></content:encoded>
						                            <category domain="https://gvectors.com/forum/general-questions/">wpForo</category>                        <dc:creator>dlinstedt</dc:creator>
                        <guid isPermaLink="true">https://gvectors.com/forum/general-questions/function-call-to-assign-wpforo-user-role/#post-22298</guid>
                    </item>
				                    <item>
                        <title>function call to assign wpForo user role?</title>
                        <link>https://gvectors.com/forum/general-questions/function-call-to-assign-wpforo-user-role/#post-22294</link>
                        <pubDate>Tue, 21 Apr 2020 08:21:05 +0000</pubDate>
                        <description><![CDATA[Hi team,
As always, stellar product, fast, efficient and reliable!  Love it!
I am wondering if there is an acceptable function call in wpForo, to assign a user a new primary wpForo based r...]]></description>
                        <content:encoded><![CDATA[<p>Hi team,</p>
<p>As always, stellar product, fast, efficient and reliable!  Love it!</p>
<p>I am wondering if there is an acceptable function call in wpForo, to assign a user a new primary wpForo based role?</p>
<p>I am working with wpFusion, and when a tag changes I need to "change the wpForo role".</p>
<p>I don't want to sync with wordpress roles, for many reasons - so I am looking for an available function call in wpForo to get this done.  It would be nice if there were an API callback for this.  I am sure I am not the only one that could use this functionality (nearly everyone using wooCommerce would need this too I think).</p>
<p>Thank you kindly,</p>
<p>Dan</p>]]></content:encoded>
						                            <category domain="https://gvectors.com/forum/general-questions/">wpForo</category>                        <dc:creator>dlinstedt</dc:creator>
                        <guid isPermaLink="true">https://gvectors.com/forum/general-questions/function-call-to-assign-wpforo-user-role/#post-22294</guid>
                    </item>
							        </channel>
        </rss>
		