示例#1
0
 /**
  * Called to validate login credentials or o
  * @return string
  */
 public static function credentials_validation($id = null, $redirect = null)
 {
     // filter for the css class of the error message
     $login_status_css_class = apply_filters('pp_login_error_css_class', 'profilepress-login-status', $id);
     // catch all social login errors caught by the glaobal func below.
     /** @see connectors.php */
     global $pp_login_wp_errors;
     // initialise variable
     $login_error = '';
     if (isset($pp_login_wp_errors) && is_wp_error($pp_login_wp_errors)) {
         $login_error = '<div class="' . $login_status_css_class . '">';
         $login_error .= $pp_login_wp_errors->get_error_message();
         $login_error .= '</div>';
     }
     // filter to change login submit button name to avoid validation for forms on same page
     $submit_name = apply_filters('pp_login_submit_name', 'login_submit', $id);
     // if login form have been submitted process it
     if (isset($_POST[$submit_name])) {
         // get login form data
         $username = @esc_attr($_POST['login_username']);
         $password = @esc_attr($_POST['login_password']);
         $remember_login = @esc_attr($_POST['login_remember']);
         // $id is being included for filtering the redirection location after login
         $login_status = ProfilePress_Login_Auth::login_auth($username, $password, $remember_login, $id, $redirect);
         if (isset($login_status) && is_wp_error($login_status)) {
             $login_error = '<div class="' . $login_status_css_class . '">';
             $login_error .= $login_status->get_error_message();
             $login_error .= '</div>';
         } else {
             $login_error = '';
         }
     }
     return $login_error;
 }
 /**
  * Login form tag
  *
  * @param array $atts
  * @param string $content
  *
  * @return string
  */
 public static function login_form_tag($atts, $content)
 {
     $login_error = ProfilePress_Login_Auth::credentials_validation();
     $tag = '<form method="post" action="' . esc_url($_SERVER['REQUEST_URI']) . '">';
     $tag .= do_shortcode($content);
     $tag .= '</form>';
     return $login_error . $tag;
 }
 /** Parse login form */
 public function profilepress_login_parser($atts)
 {
     $atts = shortcode_atts(array('id' => '', 'redirect' => ''), $atts);
     // get login builder id
     $id = absint($atts['id']);
     $redirect = esc_url($atts['redirect']);
     $login_error = ProfilePress_Login_Auth::credentials_validation($id, $redirect);
     $attribution = '<!-- Custom Login form built with the ProfilePress WordPress plugin - http://profilepress.net -->' . "\r\n";
     $css = self::get_login_css($id);
     return $attribution . $css . $login_error . $this->get_login_structure($id);
 }