Advertisement
Guest User

jobroller

a guest
Apr 15th, 2012
647
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.39 KB | None | 0 0
  1. <?php
  2. /**
  3.  *
  4.  * This controls how the login, logout,
  5.  * registration, and forgot your password pages look.
  6.  * It overrides the default WP pages by intercepting the request.
  7.  *
  8.  * @version 1.0
  9.  * @author AppThemes
  10.  * @package JobRoller
  11.  * @copyright 2010 all rights reserved
  12.  *
  13.  */
  14.  
  15. global $pagenow;
  16.  
  17. // check to prevent php "notice: undefined index" msg
  18. if(isset($_GET['action'])) $theaction = $_GET['action']; else $theaction ='';
  19.  
  20. // if the user is on the login page, then let the games begin
  21. if ($pagenow == 'wp-login.php' && $theaction != 'logout' && !isset($_GET['key'])) :
  22.     add_action('init', 'jr_login_init', 98);
  23.     add_filter('wp_title', 'jr_title');
  24. endif;
  25.  
  26. // main function that routes the request
  27. function jr_login_init() {
  28.  
  29.     nocache_headers();
  30.    
  31.     if (isset($_REQUEST['action'])) :
  32.         $action = $_REQUEST['action'];
  33.     else :
  34.         $action = 'login';
  35.     endif;
  36.     switch($action) :
  37.         case 'lostpassword' :
  38.         case 'retrievepassword' :
  39.             jr_show_password();
  40.         break;
  41.         case 'register':
  42.         //case 'login':
  43.         default:
  44.             jr_registration_steps(); //func register
  45.         break;
  46.         case 'login':
  47.         default:
  48.         jr_show_login();
  49.          break;
  50.     endswitch;
  51.     exit;
  52. }
  53.  
  54. // display the meta page title based on the current page
  55. function jr_title($title) {
  56.     global $pagenow;
  57.     if ($pagenow == "wp-login.php") :
  58.         if (isset($_GET['action'])) $action = $_GET['action']; else $action='';
  59.         switch($action) :
  60.             case 'lostpassword':
  61.                 $title = __('Retrieve your lost password for ','appthemes');
  62.             break;
  63.             case 'login':
  64.             case 'register':
  65.             default:
  66.                 $title = __('Login/Register at ','appthemes');
  67.             break;
  68.         endswitch;
  69.  
  70.     elseif ($pagenow == "profile.php") :
  71.         $title = __('Your Profile at ','appthemes');
  72.     endif;
  73.     return $title;
  74. }
  75.  
  76.  
  77.  
  78. // Show login and registation forms
  79. function jr_show_login() {
  80.  
  81.     global $posted;
  82.    
  83.    
  84.        
  85.     if (isset($_POST['login']) && $_POST['login']) {
  86.  
  87.         $errors = jr_process_login_form();
  88.     }
  89.  
  90.     // Clear errors if loggedout is set.
  91.     if ( !empty($_GET['loggedout']) ) $errors = new WP_Error();
  92.  
  93.     // If cookies are disabled we can't log in even with a valid user+pass
  94.     if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
  95.             $errors->add('test_cookie', __('Cookies are blocked or not supported by your browser. You must enable cookies to continue.','appthemes'));
  96.    
  97.     if ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] )
  98.             $message = __('You are now logged out.','appthemes');
  99.            
  100.            
  101.            
  102.            
  103.            
  104.            
  105.            
  106.          get_template_part('header');
  107.     ?>
  108.    
  109.            
  110.            
  111.             <div class="section">
  112.  
  113.         <div class="section_content">
  114.  
  115.             <h1><?php _e('Loginnnn', 'appthemes'); ?></h1>
  116.            
  117.             <?php
  118.                 if (isset($message) && !empty($message)) {
  119.                     echo '<p class="success">'.$message.'</p>';
  120.                 }
  121.             ?>
  122.             <?php
  123.             if (isset($errors) && sizeof($errors)>0 && $errors->get_error_code()) :
  124.                 echo '<ul class="errors">';
  125.                 foreach ($errors->errors as $error) {
  126.                     echo '<li>'.$error[0].'</li>';
  127.                 }
  128.                 echo '</ul>';
  129.             endif;
  130.             ?>
  131.            
  132.             <?php if (get_option('jr_allow_job_seekers')=='yes') : ?>
  133.                
  134.                 <p><?php _e('You must login or create an account in order to post a job or submit your resume.', 'appthemes'); ?></p>
  135.                
  136.                 <ul>
  137.                 <li><?php _e('As a <strong>Job Seeker</strong> you\'ll be able to submit your profile, post your resume, and be found by employers.', 'appthemes'); ?></li>
  138.                
  139.                 <li><?php _e('As an <strong>employer</strong> you will be able to submit, relist, view and remove your job listings.', 'appthemes'); ?></li>
  140.                 </ul>
  141.                
  142.             <?php else : ?>
  143.                 <p><?php _e('You must login or create an account in order to post a job &ndash; this will enable you to view, remove, or relist your listing in the future.', 'appthemes'); ?></p>
  144.             <?php endif; ?>
  145.            
  146.             <div class="col-1">
  147.                
  148.                 <?php jr_login_form(); ?>
  149.  
  150.             </div>
  151.  
  152.            
  153.  
  154.             <div class="clear"></div>
  155.  
  156.         </div><!-- end section_content -->
  157.    
  158.         <div class="clear"></div>
  159.    
  160.     </div><!-- end section -->
  161.  
  162.         <div class="clear"></div>
  163.  
  164. </div><!-- end main content -->
  165.            
  166.  
  167.     <?php if (get_option('jr_show_sidebar')!=='no') get_sidebar('page'); ?>
  168.            
  169.            
  170.            
  171.             <?php
  172.  
  173.     get_template_part('footer');
  174.  
  175. }
  176.  
  177. /////////////////////////////
  178. function jr_registration_steps() {
  179.  
  180. // Show registration steps forms
  181.  
  182.     ### Prevent Caching
  183.     nocache_headers();
  184.    
  185.     jr_load_form_scripts();
  186.        
  187.     //global $post, $posted;
  188.     global  $posted;
  189.     $submitID = $post->ID;
  190.    
  191.     $posted = array();
  192.     $errors = new WP_Error();
  193.    
  194.     if (!is_user_logged_in()) :
  195.         $step = 1;
  196.     else :
  197.         $step = 2;
  198.         if (!current_user_can('can_submit_job')) : //can_submit_listing redirect to my listing
  199.             redirect_myjobs();
  200.         endif;
  201.     endif;
  202.    
  203.     if (isset($_POST['register']) && $_POST['register']) {
  204.    
  205.         $result = jr_process_register_form( get_permalink($submitID) );
  206.        
  207.         $errors = $result['errors'];
  208.         $posted = $result['posted'];
  209.  
  210.     //}
  211.     //elseif (isset($_POST['login']) && $_POST['login']) {
  212.    
  213.         //$errors = jr_process_login_form();
  214.  
  215.     }
  216.     elseif (isset($_POST['job_submit']) && $_POST['job_submit']) { 
  217.  
  218.         $result = jr_process_submit_job_form();//jr_process_submit_user_registration_form
  219.        
  220.         $errors = $result['errors'];
  221.         $posted = $result['posted'];
  222.        
  223.         if ($errors && sizeof($errors)>0 && $errors->get_error_code()) $step = 2; else $step = 3;
  224.  
  225.     }
  226.     elseif (isset($_POST['preview_submit']) && $_POST['preview_submit']) {
  227.        
  228.         $step = 4;
  229.        
  230.         $posted = json_decode($_POST['posted']);
  231.        
  232.     }
  233.     elseif (isset($_POST['confirm']) && $_POST['confirm']) {
  234.        
  235.         $step = 4;
  236.        
  237.         jr_process_confirm_job_form();//jr_process_confirm_user_registration_form
  238.        
  239.     }
  240.     elseif (isset($_POST['goback']) && $_POST['goback']) {
  241.         $posted = json_decode(stripslashes($_POST['posted']), true);
  242.     }
  243.    
  244.     if( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )   
  245.         $message = __('Thank you for registering! An email has been sent to you containing your password.','appthemes');
  246.    
  247.  get_template_part('header'); ?>
  248.  
  249.     <div class="section">
  250.    
  251.         <div class="section_content">
  252.        
  253.             <h1><?php _e('create an Account', 'appthemes'); ?></h1>
  254.  
  255.             <?php
  256.                 echo '<ol class="steps">';
  257.                 for ($i = 1; $i <= 4; $i++) :
  258.                     echo '<li class="';
  259.                     if ($step==$i) echo 'current ';
  260.                     if (($step-1)==$i) echo 'previous ';
  261.                     if ($i<$step) echo 'done';
  262.                     echo '"><span class="';
  263.                     if ($i==1) echo 'first';
  264.                     if ($i==4) echo 'last';
  265.                     echo '">';
  266.                     switch ($i) :
  267.                         case 1 : _e('Create account', 'appthemes'); break;
  268.                         case 2 : _e('Enter Profile Details', 'appthemes'); break;
  269.                         case 3 : _e('Preview/Profile Options', 'appthemes'); break;
  270.                         case 4 : _e('Confirm', 'appthemes'); break;
  271.                     endswitch;
  272.                     echo '</span></li>';
  273.                 endfor;
  274.                 echo '</ol><div class="clear"></div>';
  275.                
  276.                 // show the success message usually because a password has been emailed to new user
  277.                 if (isset($message) && !empty($message)) echo '<p class="success">'.$message.'</p>';
  278.  
  279.                 jr_show_errors( $errors );
  280.                
  281.                 switch ($step) :
  282.                    
  283.                     case 1 :
  284.                         jr_before_step_one(); // do_action hook
  285.                         ?>
  286.                         <p><?php _e('You must login or create an account in order to post a job &mdash; this will enable you to view, remove, or relist your listing in the future.', 'appthemes'); ?></p>
  287.                
  288.                         <div class="col-1">
  289.                             <?php jr_register_form( get_permalink($submitID), 'job_lister' ); ?> <!-- change job_lister to new role--->
  290.                         </div>
  291.                         <div class="col-2">        
  292.                             <?php jr_login_form( get_permalink($submitID), get_permalink($submitID) ); ?>  <!-- delete--->
  293.                         </div>
  294.                         <div class="clear"></div>
  295.                         <?php                      
  296.                         jr_after_step_one(); // do_action hook                     
  297.                         break;
  298.                     case 2 :   
  299.                         jr_before_step_two(); // do_action hook
  300.                         jr_submit_job_form(); //*****jr_submit_user_registration_form();               
  301.                         jr_after_step_two(); // do_action hook 
  302.                         break;
  303.                     case 3 :   
  304.                         jr_before_step_three(); // do_action hook
  305.                         jr_preview_job_form();  //*****jr_preview_user_registration_form();
  306.                         jr_after_step_three(); // do_action hook
  307.                         break;
  308.                     case 4 :
  309.                         jr_before_step_four(); // do_action hook
  310.                         jr_confirm_job_form();  //*****jr_confirm_user_registration_form();
  311.                         jr_after_step_four(); // do_action hook
  312.                         break;
  313.                    
  314.                 endswitch; 
  315.             ?>
  316.  
  317.         </div><!-- end section_content -->
  318.  
  319.     </div><!-- end section -->
  320.  
  321.     <div class="clear"></div>
  322.  
  323. </div><!-- end main content -->
  324.  
  325. <?php if (get_option('jr_show_sidebar')!=='no') get_sidebar('submit'); ?>
  326.  
  327. <?php
  328.  
  329.  
  330.  
  331. get_template_part('footer');
  332.  
  333. }
  334.  
  335.  
  336. // *********Show login and registation forms
  337.  
  338. //jr_registration_stepss();
  339.     //get_template_part('footer');
  340.  
  341.  
  342. // show the forgot your password page
  343. function jr_show_password() {
  344.     $errors = new WP_Error();
  345.  
  346.     if ( isset($_POST['user_login']) && $_POST['user_login'] ) {
  347.         $errors = retrieve_password();
  348.  
  349.         if ( !is_wp_error($errors) ) {
  350.             wp_redirect('wp-login.php?checkemail=confirm');
  351.             exit();
  352.         }
  353.  
  354.     }
  355.  
  356.     if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.','appthemes'));
  357.  
  358.     do_action('lost_password');
  359.     do_action('lostpassword_post');
  360.  
  361.     get_template_part('header');
  362.     ?>
  363.     <div class="section">
  364.  
  365.         <div class="section_content">
  366.            
  367.             <h1><?php _e('Password Recovery', 'appthemes'); ?></h1>
  368.            
  369.             <?php
  370.                 if (isset($message) && !empty($message)) {
  371.                     echo '<p class="success">'.$message.'</p>';
  372.                 }
  373.             ?>
  374.             <?php
  375.             if ($errors && sizeof($errors)>0 && $errors->get_error_code()) :
  376.                 echo '<ul class="errors">';
  377.                 foreach ($errors->errors as $error) {
  378.                     echo '<li>'.$error[0].'</li>';
  379.                 }
  380.                 echo '</ul>';
  381.             endif;
  382.             ?>
  383.    
  384.             <?php jr_forgot_password_form(); ?>
  385.  
  386.             <div class="clear"></div>
  387.            
  388.         </div><!-- end section_content -->
  389.    
  390.         <div class="clear"></div>
  391.    
  392.     </div><!-- end section -->
  393.  
  394.         <div class="clear"></div>
  395.  
  396. </div><!-- end main content -->
  397.  
  398. <?php if (get_option('jr_show_sidebar')!=='no') get_sidebar('page'); ?>
  399.  
  400.  
  401. <?php
  402.    
  403.     get_template_part('footer');
  404. }
  405.  
  406. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement