• Resolved Jack

    (@jack1132132)


    Hello,

    I’m using the mycred feature for payment of membership plans, however I don’t want to use the ‘mycred_default’ type. So I’ve changed these lines:

    in ./core/classes/class.arm_mycred_feature.php:

    line 7/403: public function __construct($hook_prefs=array(), $type='mycred_default')
    to public function __construct($hook_prefs=array(), $type='my_custom_type' )

    line 360/403 $mycred_current_balance = mycred_get_users_balance( $user_id ); to
    $mycred_current_balance = mycred_get_users_balance( $user_id , 'my_custom_type');

    Seems to work fine, so this it seems this could be implemented relatively easily.

    The problem for me is that I need to change this lines every update.

    • This topic was modified 3 years, 6 months ago by Jack.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Jack

    (@jack1132132)

    Overriding the ARM_mycred_feature class like this works for me:

    function arm_mycred_feature_override() {
    	
    	if (!class_exists('ARM_mycred_feature_custom') && class_exists('ARM_mycred_feature') && class_exists('myCRED_Hook') ){
    		
    		class ARM_mycred_feature_custom extends ARM_mycred_feature{
    			
    			function arm_get_mycred_points_by_user($user_id) {
    
    				$mycred_current_balance = 0;
    				if($user_id > 0 && function_exists('mycred_get_users_balance') ) {
    					//$mycred_current_balance = mycred_get_users_balance( $user_id );
    					$mycred_current_balance = mycred_get_users_balance( $user_id , 'my_custom_type');
    				}
    				return $mycred_current_balance;
    			}
    			
    			function arm_update_mycred_points_by_user($user_id, $mycred_exchange_rate, $plan_id) {
    				$return_val = false;
    				if($user_id > 0 && $plan_id > 0) {
    					$mycred_current_balance = $this->arm_get_mycred_points_by_user( $user_id );
    
    					if ($mycred_current_balance > $mycred_exchange_rate){
    
    						//$mycred_exchange_rate = -1 * ceil(((float)$mycred_exchange_rate));
    						$mycred_exchange_rate = -1 * floatval($mycred_exchange_rate);
    
    						$key = 'arm_mycred_point_key_' . $plan_id;
    						$return_val = ($this->core->add_creds(
    							$key,
    							$user_id,
    							$mycred_exchange_rate,
    							$this->prefs[$key]['log'],
    							$plan_id
    						));
    						//$return_val = true;
    
    						$arm_debug_log_data = "UserID=".$user_id.", exchange rate=".$mycred_exchange_rate.", plan id=".$plan_id;
    						do_action('arm_payment_log_entry', 'mycred', 'Update mycred points for user '.$user_id, 'armember', $arm_debug_log_data, $arm_debug_payment_log_id);
    					}
    				}
    				return $return_val;
    			}
    		}
    		
    		global $arm_mycred_feature;
    		$arm_mycred_feature = new ARM_mycred_feature_custom(array(), 'my_custom_type');
    	}
    }
    add_action( 'mycred_load_hooks', 'arm_mycred_feature_override' , 999);

    Not super safe incase there’s an update to the module and these functions in particular.

    Plugin Author reputeinfosystems

    (@reputeinfosystems)

    Hello,

    I understood your concern and the myCred feature is available in the ARMember pro plugin so if you are using ARMember pro then, kindly open a support ticket from https://support.arpluginshop.com, and after that, the ARMember pro plugin support staff will assist you further.

    Thanks

    Plugin Author reputeinfosystems

    (@reputeinfosystems)

    Hello,

    For a week haven’t heard back from you so now this thread is closing.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Mycred feature: Changing point type.’ is closed to new replies.