confirm.php 724 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. $code = sanitise_string(get_input('c', FALSE));
  3. $user_guid = get_input('u', FALSE);
  4. // new users are not enabled by default.
  5. $access_status = access_get_show_hidden_status();
  6. access_show_hidden_entities(true);
  7. $user = get_entity($user_guid);
  8. if (!$code || !$user || !uservalidationbyemail_validate_email($user_guid, $code)) {
  9. register_error(elgg_echo('email:confirm:fail'));
  10. forward();
  11. }
  12. elgg_push_context('uservalidationbyemail_validate_user');
  13. system_message(elgg_echo('email:confirm:success'));
  14. $user = get_entity($user_guid);
  15. $user->enable();
  16. elgg_pop_context();
  17. try {
  18. login($user);
  19. } catch(LoginException $e){
  20. register_error($e->getMessage());
  21. }
  22. access_show_hidden_entities($access_status);
  23. forward();