pmpro_getDiscountCode

The Paid Memberships Pro pmpro getDiscountCode function.

Description

pmpro_getDiscountCode( (constant) $seed = NULL ); 

Parameters (1)

0. $seed — Optional. (constant) => NULL
The seed.

Usage

  1. if ( !function_exists( 'pmpro_getDiscountCode' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/functions.php'; 
  3.  
  4. // The seed. 
  5. $seed = NULL; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = pmpro_getDiscountCode($seed); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/functions.php  
  1. function pmpro_getDiscountCode($seed = NULL) 
  2. global $wpdb; 
  3.  
  4. while(empty($code)) 
  5. $scramble = md5(AUTH_KEY . current_time('timestamp') . $seed . SECURE_AUTH_KEY); 
  6. $code = substr($scramble, 0, 10); 
  7. $check = $wpdb->get_var("SELECT code FROM $wpdb->pmpro_discount_codes WHERE code = '" . esc_sql($code) . "' LIMIT 1"); 
  8. if($check || is_numeric($code)) 
  9. $code = NULL; 
  10.  
  11. return strtoupper($code);