Plugin: Achievements

Join this plugin group to follow comments, support topics and reviews.

Custom achievement (5 posts)

Started 1 year, 2 months ago by: driz

  • How would I go about creating a custom achievement?

    As on my site I have built a function that allows users to accept comments as accepted answers to questions (these are posts). So for example if someone successfully had there comment chosen then they would unlock an achievement for how many times they did it etc.

    This is what the function looks like:

    <?php
    
    				function wp_accept_favor($wp_comment_id)
    				{
    
    					// Add accepted value of true to the comment
    					add_comment_meta( $wp_comment_id, 'accepted', true );
    
    					$favor_email = get_comment_author_email($wp_comment_id);
    
    					$favor_message = 'Your favor has been accepted';
    
    					// send email to comment author
    					wp_mail($favor_email, 'Favorr.me - Your favor has been accepted!', $favor_message);
    
    					// Close the post from further comments
    					$current_post = array('comment_status' => 'closed');
    
    					$updated_post = wp_update_post( $current_post );
    					wp_redirect($post->guid);
    
    				}
    
    				/*if(isset($_GET['wp_accept_favor']))*/
    				if(isset($_GET['wp_accept_favor']) && !empty($_GET['wp_accept_favor']))
    				{
    				    wp_accept_favor((int)$_GET['wp_accept_favor']);
    				}
    
    				?>

    So the idea is when I run this function it closes the post and adds some special meta data to the comment that was accepted by passing in the comment id. So what I need to do is have the achievements plugin give points based on how many of these comments a user has had accepted.

    Can anyone help? Thanks

  • Profile picture of Paul Gibbs Paul Gibbs said 1 year, 2 months ago:

    http://achievementsapp.com/developer/add-support-for-a-plugin-non-custom-post-type/

  • Mine is neither a post type or a plugin. It’s just a simple function that adds some meta data and closes the post.

  • Profile picture of Paul Gibbs Paul Gibbs said 1 year, 1 month ago:

    Doesn’t matter. Achievements works based on do_action calls.

  • Profile picture of nyroka nyroka said 5 months, 1 week ago:

    Hello, is there a way for me to customize wordpress achievements.

    I have a website that I would like to pay members with points to complete offers or tasks.

    Can I use achievements to do this?

    Thanking you in advance.