Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. function login_overlay_menu() {
  2. $items['login-overlay'] = array(
  3. 'title' => t('Sign in'),
  4. 'page callback' => 'login_overlay_callback',
  5. 'page arguments' => array(),
  6. 'type' => MENU_CALLBACK,
  7. 'access callback' => TRUE,
  8. );
  9. return $items;
  10. }
  11.  
  12. function login_overlay_callback($js = TRUE){
  13. ctools_include('modal');
  14. ctools_include('ajax');
  15. $form_state = array(
  16. 'ajax' => TRUE,
  17. );
  18. $output = ctools_modal_form_wrapper('login_overlay_form', $form_state);
  19. if (isset($_GET['destination'])) {
  20. $output[] = login_overlay_redirect($_GET['destination']);
  21. }
  22. else {
  23. $output[] = ctools_ajax_command_reload();
  24. }
  25. print ajax_render($output);
  26. }
  27.  
  28. function login_overlay_redirect($path) {
  29. global $user;
  30. if (isset($languages[$user->language])) {
  31. $options = array('language' => $languages[$user->language]);
  32. }
  33. return ctools_ajax_command_redirect($path, 0, $options);
  34. }
  35.  
  36. /**
  37. * Implements hook_user_login().
  38. */
  39. function my_module_user_login(&$edit, $account) {
  40. // $edit is empty with one time login
  41. if (!empty($edit)) {
  42. $_GET['destination'] = 'some-url';
  43. }
  44. // Or the form id is the password reset form
  45. if ($_POST['form_id'] != 'user_pass_reset') {
  46. $_GET['destination'] = 'some-url';
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement