Community Support Forums — WordPress® ( Users Helping Users ) — 2011-08-11T01:21:47-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=14397 2011-08-11T01:21:47-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14397&p=30483#p30483 <![CDATA[Re: Demoting users with PHP]]>

Statistics: Posted by Cristián Lávaque — August 11th, 2011, 1:21 am


]]>
2011-08-11T01:17:07-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14397&p=30482#p30482 <![CDATA[Re: Demoting users with PHP]]>
correct syntax is: \
Code:
$user->set_role( 's2member_level'. $demote_to );


thanks for the help!

Statistics: Posted by randomskate1 — August 11th, 2011, 1:17 am


]]>
2011-08-10T22:15:59-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14397&p=30481#p30481 <![CDATA[Re: Demoting users with PHP]]>
Code:
$user = new WP_User(21);
$user->set_role('s2member_level2'); 


Go to his profile and see if the role got updated.

Statistics: Posted by Cristián Lávaque — August 10th, 2011, 10:15 pm


]]>
2011-08-10T21:44:48-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14397&p=30479#p30479 <![CDATA[Re: Demoting users with PHP]]>
With a closer look into the database in the wp_usermeta table, I found that "s2member_levelXX" seems to be the proper convention (from my understanding), but this still doesn't work, just demotes to 0. setting "subscriber" works but this is not what i want... is there an alternative for the set_role() function ?

Statistics: Posted by randomskate1 — August 10th, 2011, 9:44 pm


]]>
2011-08-10T21:03:04-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14397&p=30476#p30476 <![CDATA[Re: Demoting users with PHP]]>
Code:
get_current_user_id()


instead of
Code:
wp_get_current_user()

Statistics: Posted by Bruce C — August 10th, 2011, 9:03 pm


]]>
2011-08-10T20:19:37-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14397&p=30473#p30473 <![CDATA[Re: Demoting users with PHP]]>
Cheers

Statistics: Posted by randomskate1 — August 10th, 2011, 8:19 pm


]]>
2011-08-10T19:59:38-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14397&p=30472#p30472 <![CDATA[Re: Demoting users with PHP]]>
I am calling the set_role function from within messages_screen_compose() in bp-messages.php under the condition that the message successfully sends, but in either case, the user gets demoted to level 0 instead of level 81.

Code:
$current_user = wp_get_current_user();
$user = new WP_User($current_user->ID);
$user->set_role('s2Member Level 81');


Code:
$user = new WP_User(bp_current_user_id());
$user->set_role('s2Member Level 81');


Thanks!

Statistics: Posted by randomskate1 — August 10th, 2011, 7:59 pm


]]>
2011-08-10T19:34:27-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14397&p=30471#p30471 <![CDATA[Re: Demoting users with PHP]]>
You need to get the user's ID in WordPress, it's a unique number for that user. It may be obviously available in the code where you're adding this customization, or you can study these WordPress functions to find a way to get it https://codex.wordpress.org/Function_Re ... _Functions

Statistics: Posted by Cristián Lávaque — August 10th, 2011, 7:34 pm


]]>
2011-08-10T19:26:07-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14397&p=30470#p30470 <![CDATA[Re: Demoting users with PHP]]> bp_current_user_id() give you the WordPress user ID?

Statistics: Posted by Cristián Lávaque — August 10th, 2011, 7:26 pm


]]>
2011-08-10T19:21:22-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14397&p=30467#p30467 <![CDATA[Re: Demoting users with PHP]]>
Code:
$user = new WP_User(bp_current_user_id());
$user->set_role(81);


Code:
$user = new WP_User(bp_current_user_id());
$user->set_role('level_81');


Code:
$user = new WP_User(bp_current_user_id());
$user->set_role('s2Member Level 81');


Code:
$user = new WP_User(bp_current_user_id());
$user->set_role('s2MemberLevel81');


... These are just some of the things I've tried without any success. Cheers for the help

Statistics: Posted by randomskate1 — August 10th, 2011, 7:21 pm


]]>
2011-08-10T18:13:51-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14397&p=30451#p30451 <![CDATA[Re: Demoting users with PHP]]> Statistics: Posted by Cristián Lávaque — August 10th, 2011, 6:13 pm


]]>
2011-08-10T17:41:55-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14397&p=30446#p30446 <![CDATA[Re: Demoting users with PHP]]> Statistics: Posted by randomskate1 — August 10th, 2011, 5:41 pm


]]>
2011-08-10T12:11:54-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14397&p=30388#p30388 <![CDATA[Re: Demoting users with PHP]]>
Code:
$user = new WP_User($user_id);
$user->set_role('subscriber');
 

Statistics: Posted by Cristián Lávaque — August 10th, 2011, 12:11 pm


]]>
2011-08-10T08:11:18-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14397&p=30365#p30365 <![CDATA[Demoting users with PHP]]>
Code:
$demote_to = S2MEMBER_CURRENT_USER_ACCESS_LEVEL – $demotion_value;
(works fine)
but THEN…this:

Code:
$demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role ($demote_to);


or this:
Code:
$demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role ( ‘s2Member Level ‘ . $demote_to);


doesn’t work. I cannot find much documentation anywhere about this function either, It will refuse to demote the member, any help will be appreciated a lot. Thanks!

Statistics: Posted by randomskate1 — August 10th, 2011, 8:11 am


]]>