/**
 * Determines whether or not the affiliate is active
 *
 * If no affiliate ID is given, it will check the currently logged in affiliate
 *
 * @since 1.6
 * @return int
 */
function affwp_is_active_affiliate($affiliate_id = 0)
{
    if (empty($affiliate_id)) {
        $affiliate_id = affwp_get_affiliate_id();
    }
    if ('active' == affwp_get_affiliate_status($affiliate_id)) {
        return true;
    }
    return false;
}
Ejemplo n.º 2
0
 function test_set_affiliate_status()
 {
     $this->assertEquals('active', affwp_get_affiliate_status($this->_affiliate_id));
     $this->assertTrue(affwp_set_affiliate_status($this->_affiliate_id, 'inactive'));
     $this->assertEquals('inactive', affwp_get_affiliate_status($this->_affiliate_id));
     $this->assertTrue(affwp_set_affiliate_status($this->_affiliate_id, 'pending'));
     $this->assertEquals('pending', affwp_get_affiliate_status($this->_affiliate_id));
     $this->assertTrue(affwp_set_affiliate_status($this->_affiliate_id, 'rejected'));
     $this->assertEquals('rejected', affwp_get_affiliate_status($this->_affiliate_id));
     $this->assertTrue(affwp_set_affiliate_status($this->_affiliate_id, 'active'));
     $this->assertEquals('active', affwp_get_affiliate_status($this->_affiliate_id));
 }
Ejemplo n.º 3
0
	<?php 
} elseif ('rejected' == affwp_get_affiliate_status(affwp_get_affiliate_id())) {
    ?>

		<p class="affwp-notice"><?php 
    _e('Your affiliate account request has been rejected', 'affiliate-wp');
    ?>
</p>

	<?php 
}
?>

	<?php 
if ('active' == affwp_get_affiliate_status(affwp_get_affiliate_id())) {
    ?>

		<?php 
    do_action('affwp_affiliate_dashboard_top', affwp_get_affiliate_id());
    ?>

		<?php 
    if (!empty($_GET['affwp_notice']) && 'profile-updated' == $_GET['affwp_notice']) {
        ?>

			<p class="affwp-notice"><?php 
        _e('Your affiliate profile has been updated', 'affiliate-wp');
        ?>
</p>
Ejemplo n.º 4
0
 /**
  * Register a user as an affiliate during user registration
  *
  * @since 1.1
  * @return bool
  */
 public function auto_register_user_as_affiliate($user_id = 0)
 {
     if (!affiliate_wp()->settings->get('auto_register')) {
         return;
     }
     if (did_action('affwp_affiliate_register')) {
         return;
     }
     $affiliate_id = affwp_add_affiliate(array('user_id' => $user_id));
     if (!$affiliate_id) {
         return;
     }
     $status = affwp_get_affiliate_status($affiliate_id);
     $user = (array) get_userdata($user_id);
     $args = (array) $user['data'];
     /**
      * Fires after a new user has been auto-registered as an affiliate
      *
      * @since  1.7
      * @param  int    $affiliate_id
      * @param  string $status
      * @param  array  $args
      */
     do_action('affwp_auto_register_user', $affiliate_id, $status, $args);
 }
Ejemplo n.º 5
0
 /**
  * Check if it is a valid affiliate
  *
  * @since 1.0
  */
 public function is_valid_affiliate($affiliate_id = 0)
 {
     if (empty($affiliate_id)) {
         $affiliate_id = $this->get_affiliate_id();
     }
     $is_self = is_user_logged_in() && get_current_user_id() == affiliate_wp()->affiliates->get_column('user_id', $affiliate_id);
     $active = 'active' === affwp_get_affiliate_status($affiliate_id);
     $valid = affiliate_wp()->affiliates->affiliate_exists($affiliate_id);
     return $valid && !$is_self && $active;
 }