Advertisement
Guest User

Affiliate Email

a guest
May 16th, 2017
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.85 KB | None | 0 0
  1.  
  2. /**
  3.  * affiliates-welcome-email.php
  4.  *
  5.  * Copyright (c) 2011,2012 Antonio Blanco http://www.eggemplo.com
  6.  *
  7.  * This code is released under the GNU General Public License.
  8.  * See COPYRIGHT.txt and LICENSE.txt.
  9.  *
  10.  * This code is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * This header and all notices must be kept intact.
  16.  *
  17.  * @author Antonio Blanco  
  18.  * @package affiliates-extra-tokens
  19.  * @since affiliates-extra-tokens 1.0
  20.  *
  21.  * Plugin Name: Affiliates Welcome Email
  22.  * Plugin URI: http://www.eggemplo.com
  23.  * Description: Send a welcome email to new affiliate.
  24.  * Version: 1.0
  25.  * Author: eggemplo
  26.  * Author URI: http://www.eggemplo.com
  27.  * License: GPLv3
  28.  */
  29. define( 'AFFILIATES_WELCOME_EMAIL_DOMAIN', 'affiliateswelcomeemail' );
  30. define( 'AFFILIATES_WELCOME_EMAIL_FILE', __FILE__ );
  31. class Affiliates_Welcome_Email_Plugin {
  32.    
  33.     private static $notices = array();
  34.    
  35.     public static function init() {
  36.         add_action( 'init', array( __CLASS__, 'wp_init' ) );
  37.         add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
  38.     }
  39.    
  40.     public static function wp_init() {
  41.         if ( !defined ( 'AFFILIATES_PLUGIN_DOMAIN' ) )  {
  42.             self::$notices[] = "<div class='error'>" . __( '<strong>Affiliates Welcome Email</strong> plugin requires <a href="http://www.itthinx.com/plugins/affiliates-pro" target="_blank">Affiliates Pro</a> or <a href="http://www.itthinx.com/plugins/affiliates-enterprise" target="_blank">Affiliates Enterprise</a>.', AFFILIATES_WELCOME_EMAIL_DOMAIN ) . "</div>";
  43.         } else {
  44.        
  45.             add_action( "affiliates_added_affiliate", array(__CLASS__, "affiliates_added_affiliate" ) );
  46.         }
  47.        
  48.     }
  49.        
  50.    
  51.     public static function admin_notices() {
  52.         if ( !empty( self::$notices ) ) {
  53.             foreach ( self::$notices as $notice ) {
  54.                 echo $notice;
  55.             }
  56.         }
  57.     }
  58.    
  59.    
  60.     public static function affiliates_added_affiliate ($affiliate_id) {
  61.         $affiliate = affiliates_get_affiliate( $affiliate_id );
  62.        
  63.         if ( ( $affiliate ) && ( strlen( $affiliate['email'] ) > 0 ) ) {
  64.             $headers = 'From: ' . get_option( 'blogname' ) . ' <' . get_option( 'admin_email' ) .'>' . "\r\n";
  65.             $to = $affiliate['email'];
  66.            
  67. //          $subject = 'Welcome to the affiliates program';
  68. //          $message = 'Thanks to subscribe to the affiliates program.';
  69.  
  70.             $subject = 'Welcome from Accelerating Young Minds!';
  71.             $message = 'Welcome to the AYM Families in Education Program!
  72.             Username: [username]<br/>
  73.             Password: [password]<br/>
  74.             Login <a href="http://www.acceleratingyoungminds.com/fie-hub/">here</a><br/>
  75.             <br/>
  76.             Thanks for joining the AYM Families in Education program.<br/>';
  77.            
  78.             @wp_mail( $to, $subject, $message, $headers );
  79.         }
  80.     }
  81. }
  82. Affiliates_Welcome_Email_Plugin::init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement