M_AddSimpleInviteFieldProcess

The Membership 2 M AddSimpleInviteFieldProcess function.

Description

M_AddSimpleInviteFieldProcess( $error ); 

Parameters (1)

0. $error
The error.

Usage

  1. if ( !function_exists( 'M_AddSimpleInviteFieldProcess' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'membership-2/app_old/membershipincludes/addons/simple.invitecodes.php'; 
  3.  
  4. // The error. 
  5. $error = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = M_AddSimpleInviteFieldProcess($error); 
  9.  

Defined (1)

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

/app_old/membershipincludes/addons/simple.invitecodes.php  
  1. function M_AddSimpleInviteFieldProcess( $error ) { 
  2.  
  3. $Msi_options = M_get_option('membership_simpleinvite_options', array()); 
  4. if(empty($Msi_options['inviterequired']) || $Msi_options['inviterequired'] != 'yes') { 
  5. return $error; 
  6.  
  7. $thekey = $_POST['invitecode']; 
  8.  
  9. if(empty($thekey)) { 
  10.  
  11. if(empty($error->errors)) { 
  12. $error = new WP_Error(); 
  13.  
  14. $error->add('enterinvitecode', __('You need to enter an invite code in order to register.', 'membership')); 
  15.  
  16. } else { 
  17.  
  18. $codes = explode("\n", $Msi_options['invitecodes']); 
  19. $codes = array_map('trim', $codes); 
  20.  
  21. if(!in_array( $thekey, $codes )) { 
  22.  
  23. if(empty($error->errors)) { 
  24. $error = new WP_Error(); 
  25.  
  26. $error->add('incorrectinvitecode', __('Sorry, but we do not seem to have that code on file, please try another.', 'membership')); 
  27.  
  28. } else { 
  29. if(empty($error->errors)) { 
  30. if($Msi_options['inviteremove'] == 'yes') { 
  31. $key = array_search( $thekey, $codes); 
  32. if($key !== false) { 
  33. unset($codes[$key]); 
  34. $Msi_options['invitecodes'] = implode("\n", $codes); 
  35.  
  36. M_update_option('membership_simpleinvite_options', $Msi_options); 
  37.  
  38. return $error; 
  39.