WordPress.org

Ready to get started?Download WordPress

Forums

Achievements for WordPress
[resolved] Using Achievements to 'Promote' user role (8 posts)

  1. dscottangle
    Member
    Posted 1 year ago #

    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

    http://wordpress.org/extend/plugins/achievements/

  2. Paul Gibbs
    BuddyPress Lead Developer
    Plugin Author

    Posted 1 year ago #

    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.

  3. dscottangle
    Member
    Posted 1 year ago #

    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

  4. mikebronner
    Member
    Posted 1 year ago #

    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.

  5. dscottangle
    Member
    Posted 1 year ago #

    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

  6. mikebronner
    Member
    Posted 1 year ago #

    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

  7. Peter Hudson
    Member
    Posted 1 year ago #

    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 :)

  8. Paul Gibbs
    BuddyPress Lead Developer
    Plugin Author

    Posted 1 year ago #

    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 :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic