start.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Make elgg invite only.
  4. *
  5. * @see Readme.md for details
  6. *
  7. * @licence GNU Public License version 2
  8. * @link https://github.com/mapkyca/elgg-invite-only
  9. * @link http://www.marcus-povey.co.uk
  10. * @author Marcus Povey <marcus@marcus-povey.co.uk>
  11. */
  12. elgg_register_event_handler('init','system', function() {
  13. elgg_register_page_handler('register', function($pages) {
  14. // Get invite code details
  15. $friend_guid = (int) get_input('friend_guid', 0);
  16. $friend = get_entity($friend_guid);
  17. $invitecode = get_input('invitecode');
  18. // Validate
  19. if (($friend) && ($invitecode) && elgg_validate_invite_code($friend->username, $invitecode))
  20. {
  21. require_once(dirname(dirname(dirname(__FILE__))) . '/pages/account/register.php');
  22. }
  23. else {
  24. elgg_unregister_action('register');
  25. require_once(dirname(__FILE__) . '/pages/denied.php');
  26. }
  27. return true;
  28. });
  29. });