$membersNoEmails = array();
$formErrors = array();
$userInfo = array();
+ $userLoggingIn = false;
if ( isset( $_SESSION['travel-list'] ) ) {
foreach ( $_SESSION['travel-list'] as $item ) {
case 'login':
$email = filter_var( $_REQUEST['username'], FILTER_VALIDATE_EMAIL );
$password = filter_var( $_REQUEST['password'] );
- $user_id = $this->wpdb->get_var(
- $this->wpdb->prepare(
- "SELECT id
- FROM " . GLM_MEMBERS_ITINERARY_PLUGIN_DB_PREFIX . "user
- WHERE email = %s
- AND password = md5(%s)",
- $email,
- $password
- )
- );
- if ( $user_id ) {
+ $user_id = false;
+ if ( !$email || !$password ) {
+ $loginFailed = true;
+ } else {
+ $user_id = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT id
+ FROM " . GLM_MEMBERS_ITINERARY_PLUGIN_DB_PREFIX . "user
+ WHERE email = %s
+ AND password = md5(%s)",
+ $email,
+ $password
+ )
+ );
+ }
+ if ( $user_id && !$loginFailed ) {
// Success login
+ $userLoggingIn = true;
+
$_SESSION['itinerary-auth'] = $user_id;
$userLoggedIn = true;
// Get any stored sessions
} else {
$loginFailed = true;
}
- global $wp;
$tripPlannerPage = get_permalink( $this->config['settings']['itinerary_page'] );
- // Redirect to trip planner page
- // if ( $tripPlannerPage ) {
- // wp_redirect( $tripPlannerPage );
- // exit;
- // }
// $view = 'login.html';
break;
case 'forgot':
'token' => $token,
'helpUrl' => GLM_MEMBERS_ITINERARY_PLUGIN_URL . 'templates/helpme.html',
'sendFormSubmit' => $sendFormSubmit,
+ 'userLoggingIn' => $userLoggingIn,
);
error_reporting(E_ALL ^ E_NOTICE);
jQuery(document).ready(function($){
var glm_itinerary_page_url = '{$thisUrl}';
+ {if $userLoggingIn}
+ window.location.href = '{$thisUrl}';
+ {/if}
+
$('.glm-itinerary-delete').on('click', function(e){
e.preventDefault();
var member_id = $(this).data('id');
});
</script>
+{else}
+<script>
+ jQuery(document).ready(function($){
+ {if $userLoggingIn}
+ window.location.href = '{$thisUrl}';
+ {/if}
+
+ });
+</script>
{/if}