• Resolved dscottangle

    (@dscottangle)


    Hi Paul,

    Thanks so much for this plugin, as well as your other work, of course.

    What I’m trying to achieve is the ability to ‘promote’ a user’s role based on their level of activity.

    e.g. If a member has successfully had 10 posts approved and published, they automatically awarded a new badge and promoted to Author.

    I appreciate that this may have been covered in the past, and may required me to dig into code (it’s okay, I’m not afraid to get my hands dirty), but any help you could throw my way would be greatly appreciated.

    Many thanks,

    Scott

    https://www.ads-software.com/extend/plugins/achievements/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Paul Wong-Gibbs

    (@djpaul)

    Do you know how to programatically change the user’s role? If you can figure that bit out, I can try to help tieing that into an achievement unlock.

    Thread Starter dscottangle

    (@dscottangle)

    This is all I’ve been able to find – I really hope it’s helpful…

    Found at StackExchange

    Concept

    // NOTE: Of course change 3 to the appropriate user ID
    $u = new WP_User( 3 );
    
    // Remove role
    $u->remove_role( 'subscriber' );
    
    // Add role
    $u->add_role( 'editor' );

    Example Usage

    $blogusers = get_users('&role=student');
    
    foreach ($blogusers as $user) {
    
        $thisYear = date('Y-7');
        $gradYear = date(get_the_author_meta( 'graduation_year', $user->ID ).'-7');
    
        if($gradYear < $thisYear) {
            $u = new WP_User( $user->ID );
            // Remove role
            $u->remove_role( 'student' );
    
            // Add role
            $u->add_role( 'adult' );
        }
    }

    Again, this comes from people who know far more about it than I.

    – Scott

    I think there may be some difficulty in dealing with plugins that allow modification of roles, like Members plugin, that allow you to granularly add roles, as well as roles introduced in other plugins, like bbPress.

    I’m just thinking off the top of my head that we would have to devise a way to allow any given role to be associated with a certain number of karma points. Perhaps if we can code this without even needing to know what the roles are specifically, i.e. hard-coding them as shown above, this could actually work. ?? I don’t have a solution, just brainstorming.

    Thread Starter dscottangle

    (@dscottangle)

    Thanks Mike, I like how you’re expanding the ‘perceptive scope’ – sorry, I just couldn’t think how else to word it :~P – by suggesting ways it might work.

    Using karma points would work for some things, but for others it would need to be more specific, e.g. a member who has submitted 20 original and ‘suitable’ photos to the community gallery may earn a promotion to Photographer, with the same authority to self-publish (at least with regards to images) as the Author role. Of course this type of promotion could only be awarded based on a specific type of activity.

    Perhaps there’s scope here for an A4WP (nod to Mike) add-on to act as intermediary between A4WP and a user-role plugin (e.g. Membership+, etc…), so that when an achievement is triggered, by award or event, it will check to see if the users role needs to be added to|amended.

    I fully accept that this might be an unreasonable feature expectation, but I’m a concepts guy, so it’s in my remit to stretch, push and challenge.

    However, I think adding this kind of functionality – i.e. automatically adjusting the scope of a users role based upon their actual activity – has huge potential for enhancing a dynamic, community based website.

    This could even be further extended with the possible future feature of users|members being able to award each other ‘helping’ points (or, whatever) and possibly elevating someone to a Moderator role by community consensus – for example.

    Just thoughts I’m throwing out into the ether, but with a sense of hope as well.

    Later,

    Scott

    HI Scott,

    Good thoughts and ideas there. I am working on some of them — not sure if I can get them figured out or what, but am looking for similar functionality.

    I think we are talking about 4 distinctive systems here:
    – Award achievement based on karma points.
    – Allow multiple awarding of the same achievement (i.e. upload 20 pictures).
    – Allow achievements to have dependency on other achievements (receiving the picture upload achievement multiple times to unlock the Photographer achievement).
    – Allow manipulation of user roles when achievements are earned.

    The ones I am working on (because I need them as well) are:
    – assigning same achievement multiple times
    – achievement awarded based on completion of all dependent achievements

    I like the karma points-based achievement idea as well, and can see a use for that in my implementation of A4WP ?? as well. I’ll start a new “hack” topic once I figure these things out — just sharing where I stand at the moment, please keep this thread going, lots of good ideas.

    ~Mike

    Hi I know this is closed but I too have think that awards based on karma points would be very very useful. Not having delved into it AT ALL, would it not be possible to run a check to see if a user qualifies for an award when the points are increased?

    I know its me thinking much too simply ??

    Plugin Author Paul Wong-Gibbs

    (@djpaul)

    I used to do something similar in an older version of the plugin, then I had to shoe-horn in a bunch of code to prevent infinite loops ??

    It’s certainly something that I would reconsider for a future version, but not soon. Next version’s gonna be about Leaderboards ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Using Achievements to 'Promote' user role’ is closed to new replies.