public function enter_email_and_key_step($show_errors = true) { global $wpdb; $errors = array(); $messages = $this->messages; $form = array('ad_email' => awpcp_post_param('ad_email'), 'ad_key' => awpcp_post_param('ad_key'), 'attempts' => (int) awpcp_post_param('attempts', 0)); if ($form['attempts'] == 0 && get_awpcp_option('enable-user-panel') == 1) { $url = admin_url('admin.php?page=awpcp-panel'); $message = __('You are currently not logged in, if you have an account in this website you can log in and go to the Ad Management panel to edit your Ads.', 'AWPCP'); $message = sprintf('%s <a href="%s">%s</a>', $message, $url, __('Click here', 'AWPCP')); $this->messages[] = $message; } $send_access_key_url = add_query_arg(array('step' => 'send-access-key'), $this->url()); if (empty($form['ad_email'])) { $errors['ad_email'] = __('Please enter the email address you used when you created your Ad in addition to the Ad access key that was emailed to you after your Ad was submitted.', 'AWPCP'); } else { if (!is_email($form['ad_email'])) { $errors['ad_email'] = __('Please enter a valid email address.', 'AWPCP'); } } if (empty($form['ad_key'])) { $errors['ad_key'] = __('Please enter your Ad access key.', 'AWPCP'); } if (empty($errors)) { $this->ad = AWPCP_Ad::find_by_email_and_key($form['ad_email'], $form['ad_key']); if (is_null($this->ad)) { $errors[] = __('The email address and access key you entered does not match any of the Ads in our system.', 'AWPCP'); } else { return $this->details_step(); } } else { if ($form['attempts'] == 0 || $show_errors === false) { $errors = array(); } } $hidden = array('attempts' => $form['attempts'] + 1); $params = compact('form', 'hidden', 'messages', 'errors', 'send_access_key_url'); $template = AWPCP_DIR . '/frontend/templates/page-edit-ad-email-key-step.tpl.php'; return $this->render($template, $params); }