Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * This controls how the login, logout,
- * registration, and forgot your password pages look.
- * It overrides the default WP pages by intercepting the request.
- *
- * @version 1.0
- * @author AppThemes
- * @package JobRoller
- * @copyright 2010 all rights reserved
- *
- */
- global $pagenow;
- // check to prevent php "notice: undefined index" msg
- if(isset($_GET['action'])) $theaction = $_GET['action']; else $theaction ='';
- // if the user is on the login page, then let the games begin
- if ($pagenow == 'wp-login.php' && $theaction != 'logout' && !isset($_GET['key'])) :
- add_action('init', 'jr_login_init', 98);
- add_filter('wp_title', 'jr_title');
- endif;
- // main function that routes the request
- function jr_login_init() {
- nocache_headers();
- if (isset($_REQUEST['action'])) :
- $action = $_REQUEST['action'];
- else :
- $action = 'login';
- endif;
- switch($action) :
- case 'lostpassword' :
- case 'retrievepassword' :
- jr_show_password();
- break;
- case 'register':
- //case 'login':
- default:
- jr_registration_steps(); //func register
- break;
- case 'login':
- default:
- jr_show_login();
- break;
- endswitch;
- exit;
- }
- // display the meta page title based on the current page
- function jr_title($title) {
- global $pagenow;
- if ($pagenow == "wp-login.php") :
- if (isset($_GET['action'])) $action = $_GET['action']; else $action='';
- switch($action) :
- case 'lostpassword':
- $title = __('Retrieve your lost password for ','appthemes');
- break;
- case 'login':
- case 'register':
- default:
- $title = __('Login/Register at ','appthemes');
- break;
- endswitch;
- elseif ($pagenow == "profile.php") :
- $title = __('Your Profile at ','appthemes');
- endif;
- return $title;
- }
- // Show login and registation forms
- function jr_show_login() {
- global $posted;
- if (isset($_POST['login']) && $_POST['login']) {
- $errors = jr_process_login_form();
- }
- // Clear errors if loggedout is set.
- if ( !empty($_GET['loggedout']) ) $errors = new WP_Error();
- // If cookies are disabled we can't log in even with a valid user+pass
- if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
- $errors->add('test_cookie', __('Cookies are blocked or not supported by your browser. You must enable cookies to continue.','appthemes'));
- if ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] )
- $message = __('You are now logged out.','appthemes');
- get_template_part('header');
- ?>
- <div class="section">
- <div class="section_content">
- <h1><?php _e('Loginnnn', 'appthemes'); ?></h1>
- <?php
- if (isset($message) && !empty($message)) {
- echo '<p class="success">'.$message.'</p>';
- }
- ?>
- <?php
- if (isset($errors) && sizeof($errors)>0 && $errors->get_error_code()) :
- echo '<ul class="errors">';
- foreach ($errors->errors as $error) {
- echo '<li>'.$error[0].'</li>';
- }
- echo '</ul>';
- endif;
- ?>
- <?php if (get_option('jr_allow_job_seekers')=='yes') : ?>
- <p><?php _e('You must login or create an account in order to post a job or submit your resume.', 'appthemes'); ?></p>
- <ul>
- <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>
- <li><?php _e('As an <strong>employer</strong> you will be able to submit, relist, view and remove your job listings.', 'appthemes'); ?></li>
- </ul>
- <?php else : ?>
- <p><?php _e('You must login or create an account in order to post a job – this will enable you to view, remove, or relist your listing in the future.', 'appthemes'); ?></p>
- <?php endif; ?>
- <div class="col-1">
- <?php jr_login_form(); ?>
- </div>
- <div class="clear"></div>
- </div><!-- end section_content -->
- <div class="clear"></div>
- </div><!-- end section -->
- <div class="clear"></div>
- </div><!-- end main content -->
- <?php if (get_option('jr_show_sidebar')!=='no') get_sidebar('page'); ?>
- <?php
- get_template_part('footer');
- }
- /////////////////////////////
- function jr_registration_steps() {
- // Show registration steps forms
- ### Prevent Caching
- nocache_headers();
- jr_load_form_scripts();
- //global $post, $posted;
- global $posted;
- $submitID = $post->ID;
- $posted = array();
- $errors = new WP_Error();
- if (!is_user_logged_in()) :
- $step = 1;
- else :
- $step = 2;
- if (!current_user_can('can_submit_job')) : //can_submit_listing redirect to my listing
- redirect_myjobs();
- endif;
- endif;
- if (isset($_POST['register']) && $_POST['register']) {
- $result = jr_process_register_form( get_permalink($submitID) );
- $errors = $result['errors'];
- $posted = $result['posted'];
- //}
- //elseif (isset($_POST['login']) && $_POST['login']) {
- //$errors = jr_process_login_form();
- }
- elseif (isset($_POST['job_submit']) && $_POST['job_submit']) {
- $result = jr_process_submit_job_form();//jr_process_submit_user_registration_form
- $errors = $result['errors'];
- $posted = $result['posted'];
- if ($errors && sizeof($errors)>0 && $errors->get_error_code()) $step = 2; else $step = 3;
- }
- elseif (isset($_POST['preview_submit']) && $_POST['preview_submit']) {
- $step = 4;
- $posted = json_decode($_POST['posted']);
- }
- elseif (isset($_POST['confirm']) && $_POST['confirm']) {
- $step = 4;
- jr_process_confirm_job_form();//jr_process_confirm_user_registration_form
- }
- elseif (isset($_POST['goback']) && $_POST['goback']) {
- $posted = json_decode(stripslashes($_POST['posted']), true);
- }
- if( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )
- $message = __('Thank you for registering! An email has been sent to you containing your password.','appthemes');
- get_template_part('header'); ?>
- <div class="section">
- <div class="section_content">
- <h1><?php _e('create an Account', 'appthemes'); ?></h1>
- <?php
- echo '<ol class="steps">';
- for ($i = 1; $i <= 4; $i++) :
- echo '<li class="';
- if ($step==$i) echo 'current ';
- if (($step-1)==$i) echo 'previous ';
- if ($i<$step) echo 'done';
- echo '"><span class="';
- if ($i==1) echo 'first';
- if ($i==4) echo 'last';
- echo '">';
- switch ($i) :
- case 1 : _e('Create account', 'appthemes'); break;
- case 2 : _e('Enter Profile Details', 'appthemes'); break;
- case 3 : _e('Preview/Profile Options', 'appthemes'); break;
- case 4 : _e('Confirm', 'appthemes'); break;
- endswitch;
- echo '</span></li>';
- endfor;
- echo '</ol><div class="clear"></div>';
- // show the success message usually because a password has been emailed to new user
- if (isset($message) && !empty($message)) echo '<p class="success">'.$message.'</p>';
- jr_show_errors( $errors );
- switch ($step) :
- case 1 :
- jr_before_step_one(); // do_action hook
- ?>
- <p><?php _e('You must login or create an account in order to post a job — this will enable you to view, remove, or relist your listing in the future.', 'appthemes'); ?></p>
- <div class="col-1">
- <?php jr_register_form( get_permalink($submitID), 'job_lister' ); ?> <!-- change job_lister to new role--->
- </div>
- <div class="col-2">
- <?php jr_login_form( get_permalink($submitID), get_permalink($submitID) ); ?> <!-- delete--->
- </div>
- <div class="clear"></div>
- <?php
- jr_after_step_one(); // do_action hook
- break;
- case 2 :
- jr_before_step_two(); // do_action hook
- jr_submit_job_form(); //*****jr_submit_user_registration_form();
- jr_after_step_two(); // do_action hook
- break;
- case 3 :
- jr_before_step_three(); // do_action hook
- jr_preview_job_form(); //*****jr_preview_user_registration_form();
- jr_after_step_three(); // do_action hook
- break;
- case 4 :
- jr_before_step_four(); // do_action hook
- jr_confirm_job_form(); //*****jr_confirm_user_registration_form();
- jr_after_step_four(); // do_action hook
- break;
- endswitch;
- ?>
- </div><!-- end section_content -->
- </div><!-- end section -->
- <div class="clear"></div>
- </div><!-- end main content -->
- <?php if (get_option('jr_show_sidebar')!=='no') get_sidebar('submit'); ?>
- <?php
- get_template_part('footer');
- }
- // *********Show login and registation forms
- //jr_registration_stepss();
- //get_template_part('footer');
- // show the forgot your password page
- function jr_show_password() {
- $errors = new WP_Error();
- if ( isset($_POST['user_login']) && $_POST['user_login'] ) {
- $errors = retrieve_password();
- if ( !is_wp_error($errors) ) {
- wp_redirect('wp-login.php?checkemail=confirm');
- exit();
- }
- }
- if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.','appthemes'));
- do_action('lost_password');
- do_action('lostpassword_post');
- get_template_part('header');
- ?>
- <div class="section">
- <div class="section_content">
- <h1><?php _e('Password Recovery', 'appthemes'); ?></h1>
- <?php
- if (isset($message) && !empty($message)) {
- echo '<p class="success">'.$message.'</p>';
- }
- ?>
- <?php
- if ($errors && sizeof($errors)>0 && $errors->get_error_code()) :
- echo '<ul class="errors">';
- foreach ($errors->errors as $error) {
- echo '<li>'.$error[0].'</li>';
- }
- echo '</ul>';
- endif;
- ?>
- <?php jr_forgot_password_form(); ?>
- <div class="clear"></div>
- </div><!-- end section_content -->
- <div class="clear"></div>
- </div><!-- end section -->
- <div class="clear"></div>
- </div><!-- end main content -->
- <?php if (get_option('jr_show_sidebar')!=='no') get_sidebar('page'); ?>
- <?php
- get_template_part('footer');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement