• Resolved Woxxman

    (@woxxman)


    Is it possible to get this plugin working together with Disqus comments? Giving users points for comments made with Disqus?
    If not, can someone give me advice on similar comment plugins that work with myCRED?
    All in all I think that Disqus support would be a really good addition to this primising addon.

    Thanks in advance,
    Anton

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

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

    (@designbymerovingi)

    Hi.

    Try adding the following to your themes functions.php file:

    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'] );
    
    		// let the hook do the work
    		$mycred->new_comment( $comment->comment_ID, $comment->comment_approved );
    	}
    }

    Make sure the Points for Comments hook on the myCRED > Hooks page is setup and enabled and each time a comment is inserted by Disqus, the above code should fire the comment hook and award points according to your setup.

    I dont use Disqus so I have not yet had the chance to test this so please let me know of your findings. If no points are awarded, please enable WP_DEBUG to see if there are any errors.

    countnine

    (@countnine)

    need disqus support, too.
    I tried edit function.php but It’s seem not working.
    I’ll look foward to add disqus support.
    Thank you.

    Plugin Author myCred

    (@designbymerovingi)

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Points from Disqus comments?’ is closed to new replies.