• Resolved iamonlythird

    (@iamonlythird)


    I am navigating through the hooks and I can’t seem to find an option to give points to a user when they receive a comment.

    I am migrating from CubePoints and this was a feature that was very useful for our users.

    Also, can you please tell me how I can make the logs mention which post that was commented on. Cubepoints had this setup:

    For receiving a comment:

    “User-displayname” posted a comment on your post “Post-Title”

    For posting a comment:

    Comment on “Post-Title”

    The reason why this is important is because my users use the logs for general notification (similar to Facebook notifications)… to see which of their posts have had activity etc

    Finally, I noticed that the date format for logs is:

    September 29, 2013 2:11 pm

    Is it possible to change to this format:

    3 hours ago

    I apologize if any of this has already been discussed and resolved. Thank you for your time!

    https://www.ads-software.com/plugins/mycred/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author myCred

    (@designbymerovingi)

    Hi.

    @regarding Points for comments
    You can award points for users leaving comments in your myCRED Hooks. You will find them under the myCRED menu in your WordPress admin area.

    There should be a tab called “Points* for commenting”.
    *(replace points with whatever you named your points).

    You can select how many points to give for approved comments, select optionally to deduct points that are marked as spam etc.

    Under the log template for “Approved Comment” enter:

    Comment on %c_post_title%

    myCRED will then replace %c_post_title% with the post title for you. Using template tags allows you to make changes at any time at how events are logged.

    In the next version of myCRED (1.3) which is due this week, I will add the option to award points to the post author for comments. It is however not possible in 1.2.3
    This setting will be located under the same tab as it will be comment related.

    @regarding Changing the log date format
    That is correct. myCRED presents the date and time according to your General WordPress Settings. Unfortunately myCRED has no built-in feature to allow you to change this besides changing your date and time format.

    However techincally it is possible to achive this by filtering the actual function that formats your dates in WordPress. If you paste the code below in your themes functions.php file, it will change your log dates back to one week after that the original format is shown.

    add_filter( 'date_i18n', 'mycred_customize_log_date', 10, 4 );
    function mycred_customize_log_date( $j, $req_format, $i, $gmt )
    {
    	if ( ! function_exists( 'get_current_screen' ) ) return $j;
    	$screen = get_current_screen();
    	if ( $screen === NULL || $screen->id != 'toplevel_page_myCRED' ) return $j;
    
    	if ( time()-604800 > $i ) return $j;
    	$j = human_time_diff( $i ) . ' ago';
    	return $j;
    }

    Let me know if you need any further assistance.

    Thread Starter iamonlythird

    (@iamonlythird)

    Thank you very much for this comprehensive response. I look forward to the next update of myCRED.

    Regarding the date format fix, have you considered to make this the standard? Personally I experience it more readable and user friendly.

    Plugin Author myCred

    (@designbymerovingi)

    I will look into what we can do in regards of implementing it.

    Plugin Author myCred

    (@designbymerovingi)

    In 1.3 I will include a new filter which lets you make any adjustments to how the dates are shown in the log. Once you update to 1.3 you can remove the above code snippet (if used) and replace it with the following (still in your themes functions.php file):

    add_filter( 'mycred_log_date', 'mycred_customize_log_date', 10, 2 );
    function mycred_customize_log_date( $date, $unix )
    {
    	if ( time()-604800 > $unix ) return $date;
    	$date = human_time_diff( $unix ) . ' ago';
    	return $date;
    }
    Thread Starter iamonlythird

    (@iamonlythird)

    I look forward to this update Gabriel, great choice to do this, it will come handy for many developers.

    Thread Starter iamonlythird

    (@iamonlythird)

    Points for receiving comments works elegantly in v1.3

    However, is it possible to add a different log entry for it? For example: “Someone posted a comment on your post”

    Plugin Author myCred

    (@designbymerovingi)

    myCRED does not support separate messages for content authors. However most classes and functions in myCRED are pluggable so you could always create your own version of the hook class that does this.

    This was solved by Gabriel in a different thread.

    Browse to your hook settings and set points for content authors to 0. Then add this to functions.php:

    if ( function_exists( 'mycred_add' ) ) {
    	add_action( 'comment_post',              'award_new_guest_comments', 10, 2 );
    	function award_new_guest_comments( $comment_id, $comment_status )
    	{
    		if ( $comment_status == '1' )
    			award_points_for_guest_comments( 'approved', '', $comment_id );
    	}
    	add_action( 'transition_comment_status', 'award_points_for_guest_comments', 10, 3 );
    	function award_points_for_guest_comments( $new_status, $old_status, $comment )
    	{
    		// Look for approved comments
    		if ( $new_status != 'approved' ) return;
    
    		// Grab the comment object in case it is not there
    		if ( !is_object( $comment ) )
    			$comment = get_comment( $comment );
    
    		// Ignore Pingbacks or Trackbacks
    		if ( !empty( $comment->comment_type ) ) return;
    
    		// Get post author
    		$post = get_post( (int) $comment->comment_post_ID );
    		$post_author = $post->post_author;
    
    		// Check if the post author should be excluded
    		if ( mycred_exclude_user( $post_author ) === true ) return;
    
    		// Award points to author
    		mycred_add(
    			'new_comment', // reference
    			$post_author, // who to get points
    			1, // number of points to award
    			'Someone posted a comment on <a href=%c_post_url%>%c_post_title%</a>', // log template to use
    			$comment->comment_ID, // save comment id as reference id
    			array( 'ref_type' => 'comment' ) // enable support for comment related template tags
    		);
    	}
    }

    With this code, you can add your own log entry. Oh and, this gives points to content author if the commenter is guest too (the core plugin doesn’t).

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Points for receiving a comment and question about logs’ is closed to new replies.