Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. /**
  2. * Implementation of hook_perm().
  3. */
  4. function odp_perm() {
  5. return array('log in');
  6. }
  7.  
  8. /**
  9. * Implementation of hook_user
  10. * lock out without the 'log in' permission
  11. */
  12. function odp_user($op, &$edit, &$account, $category = NULL) {
  13. if ($op == 'login' && ! user_access('log in')) {
  14. drupal_set_message("You do not have access to log in.", "error");
  15. drupal_goto('logout'); //doesn't work
  16. drupal_goto('content/party-tonight'); //also doesn't work
  17. }
  18. }
  19.  
  20. /**
  21. * Implementation of hook_user
  22. * lock out without the 'log in' permission
  23. */
  24. function odp_user($op, &$edit, &$account, $category = NULL) {
  25. if ($op == 'login' && ! user_access('log in')) {
  26. global $user;
  27. $user = drupal_anonymous_user();
  28. drupal_set_message("You don't have permission to log in");
  29.  
  30. }
  31. }
  32.  
  33. /**
  34. * Implementation of hook_user
  35. * lock out without the 'log in' permission
  36. */
  37. function odp_user($op, &$edit, &$account, $category = NULL) {
  38. if ($op == 'login' && ! user_access('log in')) {
  39. drupal_set_message("You don't have permission to log in");
  40.  
  41. //prevent login
  42. header("Location: http://www.example.com/?q=logout");
  43. // header("Location: http://www.example.com/logout"); if using clean URLs
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement