You must install and activate AffiliateWP to use AffiliateWP GetResponse Add-on
'; } if ( $affwp_plugin_data['Version'] < '1.1' ) { echo 'AffiliateWP GetResponse Add-on requires AffiliateWP 1.1 or greater. Please update AffiliateWP.
settings->get( 'affwp_enable_getresponse' ); $getresponse_label = affiliate_wp()->settings->get( 'affwp_getresponse_form_label' ); $getresponse_api_key = affiliate_wp()->settings->get( 'affwp_getresponse_api_key' ); $getresponse_campaign_id = affiliate_wp()->settings->get( 'affwp_getresponse_campaign_id' ); ob_start(); if ( ! empty ( $getresponse_enabled ) && ! empty ( $getresponse_api_key ) && ! empty ( $getresponse_campaign_id ) ){ ?>
affiliates->get_by( 'affiliate_id', $affiliate_id ); $user_id = $affiliate->user_id; $getresponse_api_key = affiliate_wp()->settings->get( 'affwp_getresponse_api_key' ); if( ! empty( $_POST['affwp_getresponse_subscribe'] ) && ! empty( $getresponse_api_key ) ) { if( is_user_logged_in() ){ global $wpdb; $user_id = get_current_user_id(); $email = $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM $wpdb->users WHERE ID = '%d'", $user_id ) ); $name = $wpdb->get_var( $wpdb->prepare( "SELECT display_name FROM $wpdb->users WHERE ID = '%d'", $user_id ) ); } else{ $name = ucwords( sanitize_text_field( $_POST['affwp_user_name'] ) ); $email = sanitize_text_field( $_POST['affwp_user_email'] ); $affiliate = affiliate_wp()->affiliates->get_by( 'affiliate_id', $affiliate_id ); $user_id = $affiliate->user_id; } $this->affwp_add_to_getresponse( $name, $email, $user_id ); } return false; } //add new affiliate to campaign from the admin add new affiliate page public function affwp_getresponse_admin_add_user_to_list( $add ){ global $wpdb; $affiliate = affiliate_wp()->affiliates->get_by( 'affiliate_id', $add ); $user_id = $affiliate->user_id; $email = $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM $wpdb->users WHERE ID = '%d'", $user_id ) ); $name = $wpdb->get_var( $wpdb->prepare( "SELECT display_name FROM $wpdb->users WHERE ID = '%d'", $user_id ) ); $getresponse_api_key = affiliate_wp()->settings->get( 'affwp_getresponse_api_key' ); if( ! empty( $_POST['affwp_getresponse_subscribe'] ) && ! empty( $getresponse_api_key ) ) { $this->affwp_add_to_getresponse( $name, $email, $user_id ); } return false; } //get getresponse campaigns public function affwp_getresponse_get_campaigns(){ if ( ! class_exists( 'jsonRPCClient' ) ) require_once( 'classes/jsonRPCClient.php' ); $api_url = 'http://api2.getresponse.com'; $client = new jsonRPCClient($api_url); try { $getresponse_api_key = affiliate_wp()->settings->get( 'affwp_getresponse_api_key' ); $getresponse_api_key = trim( $getresponse_api_key ); $getresponse_campaigns = array(); $campaigns = $client->get_campaigns( $getresponse_api_key ); foreach ($campaigns as $key => $value) { $getresponse_campaigns[ $key ] = $value[ 'name' ]; } return $getresponse_campaigns; } catch (Exception $e) { return false; } } //Add subscribe checkbox to the Affiliate settings dashboard page public function affwp_dashboard_getresponse_subscribe_checkbox( $affiliate_id, $user_id ){ $getresponse_enabled = affiliate_wp()->settings->get( 'affwp_enable_getresponse' ); $getresponse_label = affiliate_wp()->settings->get( 'affwp_getresponse_form_label' ); $getresponse_api_key = affiliate_wp()->settings->get( 'affwp_getresponse_api_key' ); $getresponse_campaign_id = affiliate_wp()->settings->get( 'affwp_getresponse_campaign_id' ); $subscribe_status = get_user_meta( $user_id, 'tbz_affwp_subscribed_to_getresponse', true ); if( ! $subscribe_status && $getresponse_enabled && $getresponse_api_key && $getresponse_campaign_id) { ob_start(); ?>
affiliates->get_by( 'affiliate_id', $affiliate_id ); $user_id = $affiliate->user_id; $email = $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM $wpdb->users WHERE ID = '%d'", $user_id ) ); $name = affiliate_wp()->affiliates->get_affiliate_name( $affiliate_id ); $getresponse_api_key = affiliate_wp()->settings->get( 'affwp_getresponse_api_key' ); if( ! empty( $_POST['affwp_getresponse_subscribe'] ) && $getresponse_api_key ) { $this->affwp_add_to_getresponse( $name, $email, $user_id ); } return false; } public function affwp_getresponse_export(){ $getresponse_api_key = affiliate_wp()->settings->get( 'affwp_getresponse_api_key' ); $getresponse_campaign_id = affiliate_wp()->settings->get( 'affwp_getresponse_campaign_id' ); if( $getresponse_api_key && $getresponse_campaign_id) { ?> affiliates->get_affiliates( array( 'orderby' => 'date_registered', 'order' => 'ASC', 'number' => -1, 'date' => $date ) ); if( $affiliates ) { foreach( $affiliates as $affiliate ) { global $wpdb; $user_id = $affiliate->user_id; $email = $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM $wpdb->users WHERE ID = '%d'", $user_id ) ); $name = $wpdb->get_var( $wpdb->prepare( "SELECT display_name FROM $wpdb->users WHERE ID = '%d'", $user_id ) ); $subscribe_status = get_user_meta( $user_id, 'tbz_affwp_subscribed_to_getresponse', true ); $getresponse_api_key = affiliate_wp()->settings->get( 'affwp_getresponse_api_key' ); $getresponse_enabled = affiliate_wp()->settings->get( 'affwp_enable_getresponse' ); $getresponse_campaign_id = affiliate_wp()->settings->get( 'affwp_getresponse_campaign_id' ); if( ! $subscribe_status && $getresponse_enabled && $getresponse_api_key && $getresponse_campaign_id) { $this->affwp_add_to_getresponse( $name, $email, $user_id ); } } wp_safe_redirect( admin_url( 'admin.php?page=affiliate-wp-tools&affwp_notice=affiliate_exported' ) ); exit; } } public function show_notices() { $class = 'updated'; if ( isset( $_GET['affwp_notice'] ) && $_GET['affwp_notice'] ) { switch( $_GET['affwp_notice'] ) { case 'affiliate_exported' : $message = __( 'Affiliates Exported to GetResponse', 'affiliate-wp' ); break; } } if ( ! empty( $message ) ) { echo '
' . $message . '