The MU forums have moved to WordPress.org

Increment usermeta field with "1" (3 posts)

  1. kmaz
    Member
    Posted 15 years ago #

    Hi, I am creating a "Reward" plugin which give point to the user for each comment, post and images posted.

    I first created a plugin which count the comments and posts from a user and assign points with an equation but it works only on a blog basis and I want it to work sitewide (and when the author of the post where the user posted a comment delete the post, it deletes the points to so...not a solution).

    So I decided to add a post_num and comment_num meta_value in the usermeta.It is ok it work but my only problem is that I can't find how to increase the meta_value with "1" for each post or comment.

    if ( $comment_approved == 1)
    		wp_update_comment_count($comment_post_ID);
    	update_usermeta($user_id,'comment_count','here i don't know');

    Any idea ?

    Thank you

  2. kmaz
    Member
    Posted 15 years ago #


  3. kmaz
    Member
    Posted 15 years ago #

    Ok nevermind, I found,

    if ( $comment_approved == 1)
    		wp_update_comment_count($comment_post_ID);
    		wp_update_user_comment_count($user_id);

    Then

    function wp_update_user_comment_count($user_id) {
    	global $wpdb;
    $comment_count_left = get_usermeta( $user_id, "comment_count" );
    update_usermeta( $user_id, "comment_count", $comment_count_left + 1 );
    }

About this Topic