• Hey Gabriel, how can we have different payout for each role?
    This code give to only one role:

    add_action( 'mycred_init', 'mycred_pro_monthly_payouts' );
    function mycred_pro_monthly_payouts() {
    
    	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) return;
    
    	$this_month = date( 'n' );
    	if ( get_option( 'mycred_monthly_payout', 0 ) != $this_month ) {
    
    		// Grab all users for the set role
    		$users = get_users( array(
    			'role'   => 'subscriber', // The role
    			'fields' => array( 'ID' )
    		) );
    
    		// If users were found
    		if ( $users ) {
    
    			$type = 'mycred_default';
    			$mycred = mycred( $type );
    
    			// Loop though users
    			foreach ( $users as $user ) {
    
    				// Make sure user is not excluded
    				if ( $mycred->exclude_user( $user->ID ) ) continue;
    
    				// Make sure users only get this once per month
    				if ( $mycred->has_entry( 'monthly_payout', $this_month, $user->ID, '', $type ) ) continue;
    
    				// Payout
    				$mycred->add_creds(
    					'monthly_payout',
    					$user->ID,
    					10,
    					'Monthly %_plural% payout',
    					$this_month,
    					'',
    					$type
    				);
    			}
    
    			update_option( 'mycred_monthly_payout', $this_month );
    
    		}
    
    	}
    
    }

    There’s a way to give different amount for each role?
    And how to change this monthly to weekly?

    https://wordpress.org/plugins/mycred/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Different payout amount for each role’ is closed to new replies.