Function: Update User


/ Published in: PHP
Save to your folder(s)

Code is to upgrade a user in the user management table edit


Copy this code and paste it in your HTML
  1. function upgrade_user($userID)
  2. {
  3. global $AI;
  4.  
  5. require_once( ai_cascadepath('includes/plugins/user_management/includes/class.te_user_management.php') );
  6. $te_um = new C_te_user_management();
  7. $te_um->te_mode = 'update';
  8. foreach ( $te_um->writable_db_field as $n => $v )
  9. {
  10. $te_um->writable_db_field[$n] = false;
  11. }
  12. $te_um->writable_db_field['username'] = true;
  13. $te_um->writable_db_field['password'] = true;
  14. $te_um->writable_db_field['account_type'] = true;
  15. $te_um->db['username'] = $this->db['username'];
  16. $te_um->db['password'] = $this->db['password'];
  17. $_POST['retype_password'] = $this->db['password']; // won't pass validation w/o this
  18. //$te_um->db['account_type'] = 'Member'; // don't become Member yet, this function called only at step 1 of process
  19. //$te_um->db['account_type'] = 'Pre-Enrollee';
  20. $te_um->db['account_type'] = 'Member'; // one step: can do this now
  21. $te_um->admin_section_override = true;
  22.  
  23. // SEND UPGRADE ALERT EMAIL
  24. $sponsor_userID = (int) db_lookup_value('genealogy', 'userID', $userID, 'sponsor_id');
  25. $sponsor_email = db_lookup_value('users', 'userID', $sponsor_userID, 'email');
  26. require_once( ai_cascadepath('includes/plugins/system_emails/class.system_emails.php') );
  27. $se = new C_system_emails(array());
  28. $se->util_translate_placeholders_userID = $sponsor_userID;
  29. $se->load('upgrade', 'event', 'Pre-Enrollee');
  30. $se->send_message($sponsor_email);
  31.  
  32. return $te_um->update($userID);
  33. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.