Ah I failed to take into account that there is no user ID for new comments via Discuss.
Replace the previous code with the following:
add_action( 'wp_insert_comment', 'mycred_disqus_support', 10, 2 );
function mycred_disqus_support( $id, $comment ) {
// Make sure myCRED and Disqus is installed
if ( class_exists( 'myCRED_Hook_Comments' ) && function_exists( 'dsq_is_installed' ) ) {
// Load the myCRED Comment Hook
$hooks = get_option( 'mycred_pref_hooks' );
$mycred = new myCRED_Hook_Comments( $hooks['hook_prefs'] );
// Attempt to get a comment authors ID
if ( $comment->user_id == 0 ) {
$email = get_user_by( 'email', $comment->comment_author_email );
// Failed to find author, can not award points
if ( $email === false ) return;
$comment->user_id = $email->ID;
}
// let the hook do the work
$mycred->comment_transitions( 'approved', 'unapproved', $comment );
}
}
Note that if you have disabled Comment syncing with Disqus, no points will be awarded!
Also points are awarded when the sync is completed or if you manually sync on the Disqus plugin settings page.
Will add this in to 1.4
Tested with myCRED 1.3.3.2 and Disqus 2.74