Ejemplo n.º 1
0
 /**
  * A shortcode for rendering the login form.
  *
  * @param  array   $attributes  Shortcode attributes.
  * @param  string  $content     The text content for shortcode. Not used.
  *
  * @return string  The shortcode output
  */
 public function render_login_form($attributes, $content = null)
 {
     // Parse shortcode attributes
     $default_attributes = array('show_title' => false);
     $attributes = shortcode_atts($default_attributes, $attributes);
     $show_title = $attributes['show_title'];
     if (is_user_logged_in()) {
         $url = home_url('home');
         PR_Membership::pr_redirect($url);
     }
     // Pass the redirect parameter to the WordPress login functionality: by default,
     // don't specify a redirect, but if a valid redirect URL has been passed as
     // request parameter, use it.
     $attributes['redirect'] = '';
     if (isset($_REQUEST['redirect_to'])) {
         $attributes['redirect'] = wp_validate_redirect($_REQUEST['redirect_to'], $attributes['redirect']);
     }
     // Error messages
     $errors = array();
     if (isset($_REQUEST['login'])) {
         $error_codes = explode(',', $_REQUEST['login']);
         foreach ($error_codes as $code) {
             $errors[] = $this->get_error_message($code);
         }
     }
     $attributes['errors'] = $errors;
     // Check if user just logged out
     $attributes['logged_out'] = isset($_REQUEST['logged_out']) && $_REQUEST['logged_out'] == true;
     // Render the login form using an external template
     return PR_Membership::get_html_template('login-form', $attributes);
 }
Ejemplo n.º 2
0
 public function render_search_page()
 {
     $attributes = array();
     if (isset($_REQUEST['s'])) {
         $attributes['search'] = $_REQUEST['s'];
     }
     global $query_string;
     $query_args = explode("&", $query_string);
     $search_query = array();
     foreach ($query_args as $key => $string) {
         $query_split = explode("=", $string);
         $search_query[$query_split[0]] = urldecode($query_split[1]);
     }
     // foreach
     $search = new WP_Query($search_query);
     var_dump($search);
     return PR_Membership::get_html_template('search-page', $attributes);
 }
Ejemplo n.º 3
0
 function render_signup_form($attributes)
 {
     if (isset($_POST['register'])) {
         $this->username = $_POST['username'];
         $this->email = $_POST['email'];
         $this->password = $_POST['password'];
         $attributes = $this->signup();
     }
     if (!is_user_logged_in()) {
         // check to make sure user registration is enabled
         $registration_enabled = get_option('users_can_register');
         // only show the registration form if allowed
         if ($registration_enabled) {
             return PR_Membership::get_html_template('signup-form', $attributes);
         } else {
             echo 'Registration is disabled at the moment';
         }
     }
 }