Lara Marks
Forum Replies Created
-
Forum: Plugins
In reply to: [Avatar Manager] Number of questions (migrating from User Photo plugin)I need to restrict users to local avatars only too, no gravatars. Any ETA on when this will be added?
Somehow this function stopped working on 1.3.1, did the myCRED hook change?
Works! Thank you Gabriel.
I am returning with another request of adjustment. Currently, this awards points to Content Author (author of post). So basically the author gets points for commenting on their own post.
Is there a possibility to check if the commenter is the author of post, and if so, skip/don’t award?
Here is the complete code that I use:
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 'Guest 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 ); } }
Alright! To clarify, instead of:
The number of comments per post that grants points.
I suggest:
The number of comments per post that grants points to comment author.
Oh I see now. The “Limit per post” field relates to individual commenter?
When I first came across that setting, I thought that it meant total comment limit for the post (e.g. max 100 comments from any user on each post)
Forum: Plugins
In reply to: [Add Multiple Users for WordPress] [PATCH] Lots of undefined variable fixesThank you very much for posting this. I hope that the plugin author will implement it in the next update.
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).
Ah, sorry to say but one final bug remains. It awards the post author twice if the commenter is a member (because I have set 1 point for Content Author in the core comment settings).
Can we make this custom hook to ignore giving points if the commenter is already a member, because the core plugin does that already…
edit: or the alternative would be to set points to 0 in core settings? ??
@xberg Please provide more feedback. More detail will give opportunity for plugin developer to fix any potential issues for other users.
So, have you added any custom hooks to myCRED? What is WP_DEBUG telling you? Activate it through your config file and have a look through errors and post them here. And maybe post a complete list of activated plugins, it can be useful.
Thank you!
And it did! You are a star! Cheers for your hard work, it doesn’t go unnoticed.
I enabled WP_DEBUG and it did not show errors, only these warnings:
Warning: session_start(): Cannot send session cache limiter – headers already sent (output started at public_html/wp-content/plugins/w3-total-cache/lib/W3/Cache/Memcached.php:15) in public_html/wp-content/plugins/myqaptcha/myQaptcha.php on line 44
Warning: Cannot modify header information – headers already sent by (output started at public_html/wp-content/plugins/w3-total-cache/lib/W3/Cache/Memcached.php:15) in public_html/wp-includes/comment.php on line 621
Warning: Cannot modify header information – headers already sent by (output started at public_html/wp-content/plugins/w3-total-cache/lib/W3/Cache/Memcached.php:15) in public_html/wp-includes/comment.php on line 622
Warning: Cannot modify header information – headers already sent by (output started at public_html/wp-content/plugins/w3-total-cache/lib/W3/Cache/Memcached.php:15) in public_html/wp-includes/comment.php on line 623
Warning: Cannot modify header information – headers already sent by (output started at public_html/wp-content/plugins/w3-total-cache/lib/W3/Cache/Memcached.php:15) in public_html/wp-includes/pluggable.php on line 875
About your second step, I’m not sure what you mean. I have not excluded any users from using myCRED. And I tried guest commenting on more than one post.
Did that code work on your test environment?
Cheers for the support!
Added your fix but is still not working. Posted guest comment and no update in the logs. Maybe I am doing something wrong?
This is the complete code that I use:
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 'Guest 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 ); }
And when permanently deleting a comment, these warnings are shown:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in /public_html/wp-includes/plugin.php on line 406
Warning: Cannot modify header information – headers already sent by (output started at /public_html/wp-includes/plugin.php:406) in /public_html/wp-includes/class-wp-ajax-response.php on line 129