Support Forum

Assign group to user based on reputation

YE Yehonal
Yehonal
Member

Hello SP community!

I would ask you 2 things:

1) is it possible, as title says, to assign a role/group based on reputation system?

2) what can i actually do with reputation? does it have a a functional way to use it?

3 Answers

New Answer

MP Mr Papa
Mr Papa
Member

lets start with #2… I assume you have read the plugin codex page:  https://simple-press.com/documentation/codex/plugins/our-plugins/available-plugins/plugin-reputation-system/

reputation is a way of rating users… so the more reputation  you have, the more you can give to other users… its a kind of karma way of rating users and letting other folks reading the forum the “quality” of a user… whether other people respect and value the posts from that user…  so you can bestow your reputation on other users that you feel have made valuable contributions to your forum…

as to #1, the answer is yes and no… 🙂  no, its not directly built in the plugin to automatically do that, but it can be done pretty easily using our core and plugin api…  if  you are interested in adding some custom code to do this, we can help show guide you there…

MP Mr Papa
Mr Papa
Member

first, this will be untested, so you many need to play a bit…

second, helps if you understand how wp filters/actions work:  https://codex.wordpress.org/Plugin_API

and something like this:

add_filter('sph_memberdata_update', 'my_check_reputation', 3);
function my_check_reputation($userid, $itemname, $itemdata) {
    if ($itemname == 'reputation') { # user reputation being updated
        # now check if reputation enough to warrant membership change
        if ($itemdata > 2000) { # change 2000 to anything
            sp_add_membership(1, $userid); # grant membership to usergroup 1
        } else if ($itemdata > 1000) { # a second value check
            sp_add_membership(2, $userid); # grant membership to usergroup 2           
        } # just add more if check for different values if needed (or use switch statement)
    }
}

this will grant membership to usergroup 1 if reputation is greater than 2000… If greater than 1000, membership will be granted to usergroup 2…  you can add as many checks as you like… or do whatever you want…  if using single usergroup membership, this will even handled if user loses reputation and falls below certain level…

again, untested, but should point you in the right direction…

you would put this code in the spFunctions.php file of your sp theme.. as always, we recommend a child theme before making any edits to our themes…