Ejemplo n.º 1
0
    /**
     * Creates the sidebar login form and status.
     *
     * This function determines if the user is logged in and displays either
     * a login form, or the user's login status. Typically used for a sidebar.		
     * You can call this directly, or with the widget.
     *
     * @since 2.4
     *
     * @param  string $post_to      A URL to redirect to upon login, default null.
     * @global string $wpmem_regchk
     * @global string $user_login
     */
    function wpmem_do_sidebar($post_to = null)
    {
        global $wpmem, $wpmem_regchk;
        // Used here and in the logout.
        $url = get_bloginfo('url');
        if (!$post_to) {
            if (isset($_REQUEST['redirect_to'])) {
                $post_to = $_REQUEST['redirect_to'];
            } elseif (is_home() || is_front_page()) {
                $post_to = $_SERVER['REQUEST_URI'];
            } elseif (is_single() || is_page()) {
                $post_to = get_permalink();
            } elseif (is_category()) {
                global $wp_query;
                $cat_id = get_query_var('cat');
                $post_to = get_category_link($cat_id);
            } elseif (is_search()) {
                $post_to = $url . '/?s=' . get_search_query();
            } else {
                $post_to = $_SERVER['REQUEST_URI'];
            }
        }
        // Clean whatever the url is.
        $post_to = esc_url($post_to);
        if (!is_user_logged_in()) {
            // If the user is not logged in, we need the form.
            // Defaults.
            $defaults = array('error_before' => '<p class="err">', 'error_after' => '</p>', 'fieldset_before' => '<fieldset>', 'fieldset_after' => '</fieldset>', 'inputs_before' => '<div class="div_texbox">', 'inputs_after' => '</div>', 'buttons_before' => '<div class="button_div">', 'buttons_after' => '</div>', 'error_msg' => __('Login Failed!<br />You entered an invalid username or password.', 'wp-members'), 'status_msg' => __('You are not logged in.', 'wp-members') . '<br />', 'strip_breaks' => true, 'wrap_inputs' => true, 'n' => "\n", 't' => "\t");
            /**
             * Filter arguments for the sidebar defaults.
             *
             * @since 2.9.0
             *
             * @param array An array of the defaults to be changed.
             */
            $args = apply_filters('wpmem_sb_login_args', '');
            // Merge $args with defaults.
            $args = wp_parse_args($args, $defaults);
            $form = '';
            $label = '<label for="username">' . __('Username') . '</label>';
            $input = '<input type="text" name="log" class="username" id="username" />';
            $input = $args['wrap_inputs'] ? $args['inputs_before'] . $input . $args['inputs_after'] : $input;
            $row1 = $label . $args['n'] . $input . $args['n'];
            $label = '<label for="password">' . __('Password') . '</label>';
            $input = '<input type="password" name="pwd" class="password" id="password" />';
            $input = $args['wrap_inputs'] ? $args['inputs_before'] . $input . $args['inputs_after'] : $input;
            $row2 = $label . $args['n'] . $input . $args['n'];
            $form = $row1 . $row2;
            $hidden = '<input type="hidden" name="rememberme" value="forever" />' . $args['n'] . '<input type="hidden" name="redirect_to" value="' . $post_to . '" />' . $args['n'] . '<input type="hidden" name="a" value="login" />' . $args['n'] . '<input type="hidden" name="slog" value="true" />';
            /**
             * Filter sidebar login form hidden fields.
             *
             * @since 2.9.0
             *
             * @param string $hidden The HTML for the hidden fields.
             */
            $form = $form . apply_filters('wpmem_sb_hidden_fields', $hidden);
            $buttons = '<input type="submit" name="Submit" class="buttons" value="' . __('log in', 'wp-members') . '" />';
            if ($wpmem->user_pages['profile'] != null) {
                /** This filter is documented in wp-members/inc/forms.php */
                $link = apply_filters('wpmem_forgot_link', wpmem_chk_qstr($wpmem->user_pages['profile']) . 'a=pwdreset');
                $link_html = ' <a href="' . $link . '">' . __('Forgot?', 'wp-members') . '</a>&nbsp;';
                /**
                 * Filter the sidebar forgot password.
                 *
                 * @since 3.0.9
                 *
                 * @param string $link_html
                 * @param string $link
                 */
                $link_html = apply_filters('wpmem_sb_forgot_link_str', $link_html, $link);
                $buttons .= $link_html;
            }
            if ($wpmem->user_pages['register'] != null) {
                /** This filter is documented in wp-members/inc/forms.php */
                $link = apply_filters('wpmem_reg_link', $wpmem->user_pages['register']);
                $link_html = ' <a href="' . $link . '">' . __('Register') . '</a>';
                /**
                 * Filter the sidebar register link.
                 *
                 * @since 3.0.9
                 *
                 * @param string $link_html
                 * @param string $link
                 */
                $link_html = apply_filters('wpmem_sb_reg_link_str', $link_html, $link);
                $buttons .= $link_html;
            }
            $form = $form . $args['n'] . $args['buttons_before'] . $buttons . $args['n'] . $args['buttons_after'];
            $form = $args['fieldset_before'] . $args['n'] . $form . $args['n'] . $args['fieldset_after'];
            $form = '<form name="form" method="post" action="' . $post_to . '">' . $args['n'] . $form . $args['n'] . '</form>';
            // Add status message.
            $form = $args['status_msg'] . $args['n'] . $form;
            // Strip breaks.
            $form = $args['strip_breaks'] ? str_replace(array("\n", "\r", "\t"), array('', '', ''), $form) : $form;
            /**
             * Filter the sidebar form.
             *
             * @since unknown
             *
             * @param string $form The HTML for the sidebar login form.
             */
            $form = apply_filters('wpmem_sidebar_form', $form);
            $do_error_msg = '';
            if (isset($_POST['slog']) && $wpmem_regchk == 'loginfailed') {
                $do_error_msg = true;
                $error_msg = $args['error_before'] . $args['error_msg'] . $args['error_after'];
                /**
                 * Filter the sidebar login failed message.
                 *
                 * @since unknown
                 *
                 * @param string $error_msg The error message.
                 */
                $error_msg = apply_filters('wpmem_login_failed_sb', $error_msg);
            }
            $form = $do_error_msg ? $error_msg . $form : $form;
            echo $form;
        } else {
            global $user_login;
            /** This filter is documented in wp-members/inc/dialogs.php */
            $logout = apply_filters('wpmem_logout_link', $url . '/?a=logout');
            $str = '<p>' . sprintf(__('You are logged in as %s', 'wp-members'), $user_login) . '<br />
		  <a href="' . $logout . '">' . __('click here to log out', 'wp-members') . '</a></p>';
            /**
             * Filter the sidebar user login status.
             *
             * @since unknown
             *
             * @param string $str The login status for the user.
             */
            $str = apply_filters('wpmem_sidebar_status', $str);
            echo $str;
        }
    }
Ejemplo n.º 2
0
 /**
  * Login Form Dialog.
  *
  * Builds the form used for login, change password, and reset password.
  *
  * @since 2.5.1
  *
  * @param  string $page 
  * @param  array  $arr {
  *     The elements needed to generate the form (login|reset password|forgotten password).
  *
  *     @type string $heading     Form heading text.
  *     @type string $action      The form action (login|pwdchange|pwdreset).
  *     @type string $button_text Form submit button text.
  *     @type array  $inputs {
  *         The form input values.
  *
  *         @type array {
  *
  *             @type string $name  The field label.
  *             @type string $type  Input type.
  *             @type string $tag   Input tag name.
  *             @type string $class Input tag class.
  *             @type string $div   Div wrapper class.
  *         }
  *     }
  *     @type string $redirect_to Optional. URL to redirect to.
  * }
  * @return string $form  The HTML for the form as a string.
  */
 function wpmem_login_form($page, $arr)
 {
     global $wpmem;
     // set up default wrappers
     $defaults = array('heading_before' => '<legend>', 'heading_after' => '</legend>', 'fieldset_before' => '<fieldset>', 'fieldset_after' => '</fieldset>', 'main_div_before' => '<div id="wpmem_login">', 'main_div_after' => '</div>', 'txt_before' => '[wpmem_txt]', 'txt_after' => '[/wpmem_txt]', 'row_before' => '', 'row_after' => '', 'buttons_before' => '<div class="button_div">', 'buttons_after' => '</div>', 'link_before' => '<div align="right" class="link-text">', 'link_after' => '</div>', 'form_id' => '', 'form_class' => 'form', 'button_id' => '', 'button_class' => 'buttons', 'strip_breaks' => true, 'wrap_inputs' => true, 'remember_check' => true, 'n' => "\n", 't' => "\t", 'redirect_to' => isset($_REQUEST['redirect_to']) ? esc_url($_REQUEST['redirect_to']) : (isset($arr['redirect_to']) ? $arr['redirect_to'] : get_permalink()));
     /**
      * Filter the default form arguments.
      *
      * This filter accepts an array of various elements to replace the form defaults. This
      * includes default tags, labels, text, and small items including various booleans.
      *
      * @since 2.9.0
      *
      * @param array          An array of arguments to merge with defaults. Default null.
      * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange.
      */
     $args = apply_filters('wpmem_login_form_args', '', $arr['action']);
     // Merge $args with defaults.
     $args = wp_parse_args($args, $defaults);
     // Build the input rows.
     foreach ($arr['inputs'] as $input) {
         $label = '<label for="' . $input['tag'] . '">' . $input['name'] . '</label>';
         $field = wpmem_create_formfield($input['tag'], $input['type'], '', '', $input['class']);
         $field_before = $args['wrap_inputs'] ? '<div class="' . $input['div'] . '">' : '';
         $field_after = $args['wrap_inputs'] ? '</div>' : '';
         $rows[] = array('row_before' => $args['row_before'], 'label' => $label, 'field_before' => $field_before, 'field' => $field, 'field_after' => $field_after, 'row_after' => $args['row_after']);
     }
     /**
      * Filter the array of form rows.
      *
      * This filter receives an array of the main rows in the form, each array element being
      * an array of that particular row's pieces. This allows making changes to individual 
      * parts of a row without needing to parse through a string of HTML.
      *
      * @since 2.9.0
      *
      * @param array  $rows   An array containing the form rows.
      * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange.
      */
     $rows = apply_filters('wpmem_login_form_rows', $rows, $arr['action']);
     // Put the rows from the array into $form.
     $form = '';
     foreach ($rows as $row_item) {
         $row = $row_item['row_before'] != '' ? $row_item['row_before'] . $args['n'] . $row_item['label'] . $args['n'] : $row_item['label'] . $args['n'];
         $row .= $row_item['field_before'] != '' ? $row_item['field_before'] . $args['n'] . $args['t'] . $row_item['field'] . $args['n'] . $row_item['field_after'] . $args['n'] : $row_item['field'] . $args['n'];
         $row .= $row_item['row_before'] != '' ? $row_item['row_after'] . $args['n'] : '';
         $form .= $row;
     }
     // Build hidden fields, filter, and add to the form.
     $hidden = wpmem_create_formfield('redirect_to', 'hidden', $args['redirect_to']) . $args['n'];
     $hidden = $hidden . wpmem_create_formfield('a', 'hidden', $arr['action']) . $args['n'];
     $hidden = $arr['action'] != 'login' ? $hidden . wpmem_create_formfield('formsubmit', 'hidden', '1') : $hidden;
     /**
      * Filter the hidden field HTML.
      *
      * @since 2.9.0
      *
      * @param string $hidden The generated HTML of hidden fields.
      * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange.
      */
     $form = $form . apply_filters('wpmem_login_hidden_fields', $hidden, $arr['action']);
     // Build the buttons, filter, and add to the form.
     if ($arr['action'] == 'login') {
         $args['remember_check'] = $args['remember_check'] ? $args['t'] . wpmem_create_formfield('rememberme', 'checkbox', 'forever') . '&nbsp;' . __('Remember Me') . '&nbsp;&nbsp;' . $args['n'] : '';
         $buttons = $args['remember_check'] . $args['t'] . '<input type="submit" name="Submit" value="' . $arr['button_text'] . '" class="' . $args['button_class'] . '" />' . $args['n'];
     } else {
         $buttons = '<input type="submit" name="Submit" value="' . $arr['button_text'] . '" class="' . $args['button_class'] . '" />' . $args['n'];
     }
     /**
      * Filter the HTML for form buttons.
      *
      * The string includes the buttons, as well as the before/after wrapper elements.
      *
      * @since 2.9.0
      *
      * @param string $buttons The generated HTML of the form buttons.
      * @param string $arr['action']  The action being performed by the form. login|pwdreset|pwdchange.
      */
     $form = $form . apply_filters('wpmem_login_form_buttons', $args['buttons_before'] . $args['n'] . $buttons . $args['buttons_after'] . $args['n'], $arr['action']);
     if (($wpmem->user_pages['profile'] != null || $page == 'members') && $arr['action'] == 'login') {
         /**
          * Filter the forgot password link.
          *
          * @since 2.8.0
          *
          * @param string The forgot password link.
          */
         $link = apply_filters('wpmem_forgot_link', wpmem_chk_qstr($wpmem->user_pages['profile']) . 'a=pwdreset');
         $str = __('Forgot password?', 'wp-members') . '&nbsp;<a href="' . $link . '">' . __('Click here to reset', 'wp-members') . '</a>';
         $form = $form . $args['link_before'] . apply_filters('wpmem_forgot_link_str', $str) . $args['link_after'] . $args['n'];
     }
     if ($wpmem->user_pages['register'] != null && $arr['action'] == 'login') {
         /**
          * Filter the link to the registration page.
          *
          * @since 2.8.0
          *
          * @param string The registration page link.
          */
         $link = apply_filters('wpmem_reg_link', $wpmem->user_pages['register']);
         $str = __('New User?', 'wp-members') . '&nbsp;<a href="' . $link . '">' . __('Click here to register', 'wp-members') . '</a>';
         $form = $form . $args['link_before'] . apply_filters('wpmem_reg_link_str', $str) . $args['link_after'] . $args['n'];
     }
     // Apply the heading.
     $form = $args['heading_before'] . $arr['heading'] . $args['heading_after'] . $args['n'] . $form;
     // Apply fieldset wrapper.
     $form = $args['fieldset_before'] . $args['n'] . $form . $args['fieldset_after'] . $args['n'];
     // Apply form wrapper.
     $form = '<form action="' . get_permalink() . '" method="POST" id="' . $args['form_id'] . '" class="' . $args['form_class'] . '">' . $args['n'] . $form . '</form>';
     // Apply anchor.
     $form = '<a name="' . $arr['action'] . '"></a>' . $args['n'] . $form;
     // Apply main wrapper.
     $form = $args['main_div_before'] . $args['n'] . $form . $args['n'] . $args['main_div_after'];
     // Apply wpmem_txt wrapper.
     $form = $args['txt_before'] . $form . $args['txt_after'];
     // Remove line breaks.
     $form = $args['strip_breaks'] ? str_replace(array("\n", "\r", "\t"), array('', '', ''), $form) : $form;
     /**
      * Filter the generated HTML of the entire form.
      *
      * @since 2.7.4
      *
      * @param string $form   The HTML of the final generated form.
      * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange.
      */
     $form = apply_filters('wpmem_login_form', $form, $arr['action']);
     /**
      * Filter before the form.
      *
      * This rarely used filter allows you to stick any string onto the front of
      * the generated form.
      *
      * @since 2.7.4
      *
      * @param string $str    The HTML to add before the form. Default null.
      * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange.
      */
     $form = apply_filters('wpmem_login_form_before', '', $arr['action']) . $form;
     return $form;
 }
Ejemplo n.º 3
0
 /**
  * Executes various shortcodes 
  *
  * This function executes shortcodes for pages (settings, register, login, user-list, 
  * and tos pages), as well as login status and field attributes when the wp-members tag
  * is used.  Also executes shortcodes for login status with the wpmem_logged_in tags 
  * and fields when the wpmem_field tags are used.
  *
  * @since 2.4 
  *
  * @param  array  $attr page|url|status|msg|field|id
  * @param  string $content
  * @param  string $tag
  * @return string returns the result of wpmem_do_sc_pages|wpmem_list_users|wpmem_sc_expmessage|$content
  */
 function wpmem_shortcode($attr, $content = null, $tag = 'wp-members')
 {
     // set all default attributes to false
     $defaults = array('page' => false, 'url' => false, 'status' => false, 'msg' => false, 'field' => false, 'id' => false);
     // merge defaults with $attr and extract
     extract(shortcode_atts($defaults, $attr, $tag));
     // handles the 'page' attribute
     if ($page) {
         if ($page == 'user-list') {
             //return ( function_exists( 'wpmem_list_users' ) ) ? do_shortcode( wpmem_list_users( $attr, $content ) ) : '';
             if (function_exists('wpmem_list_users')) {
                 $content = do_shortcode(wpmem_list_users($attr, $content));
             }
         } elseif ($page == 'tos') {
             return $url;
         } else {
             //return do_shortcode( wpmem_do_sc_pages( $page ) );
             $content = do_shortcode(wpmem_do_sc_pages($page));
         }
         // resolve any texturize issues...
         if (strstr($content, '[wpmem_txt]')) {
             // fix the wptexturize
             remove_filter('the_content', 'wpautop');
             remove_filter('the_content', 'wptexturize');
             add_filter('the_content', 'wpmem_texturize', 99);
         }
         return $content;
     }
     // handles the 'status' attribute
     if ($status || $tag == 'wpmem_logged_in') {
         $do_return = false;
         // if using the wpmem_logged_in tag with no attributes & the user is logged in
         if ($tag == 'wpmem_logged_in' && !$attr && is_user_logged_in()) {
             $do_return = true;
         }
         // if there is a status attribute of "in" and the user is logged in
         if ($status == 'in' && is_user_logged_in()) {
             $do_return = true;
         }
         // if there is a status attribute of "out" and the user is not logged in
         if ($status == 'out' && !is_user_logged_in()) {
             $do_return = true;
         }
         // if there is a status attribute of "sub" and the user is logged in
         if ($status == 'sub' && is_user_logged_in()) {
             if (WPMEM_USE_EXP == 1) {
                 if (!wpmem_chk_exp()) {
                     $do_return = true;
                 } elseif ($msg == true) {
                     $do_return = true;
                     $content = wpmem_sc_expmessage();
                 }
             }
         }
         // return content (or empty content) depending on the result of the above logic
         return $do_return ? do_shortcode($content) : '';
     }
     // handles the wpmem_logged_out tag with no attributes & the user is not logged in
     if ($tag == 'wpmem_logged_out' && !$attr && !is_user_logged_in()) {
         return do_shortcode($content);
     }
     // handles the 'field' attribute
     if ($field || $tag == 'wpmem_field') {
         if ($id) {
             // we are getting some other user
             if ($id == 'get') {
                 $the_user_ID = isset($_GET['uid']) ? $_GET['uid'] : '';
             } else {
                 $the_user_ID = $id;
             }
         } else {
             // get the current user
             $the_user_ID = get_current_user_id();
         }
         $user_info = get_userdata($the_user_ID);
         // @todo - check this change
         return $user_info ? htmlspecialchars($user_info->{$field}) . do_shortcode($content) : do_shortcode($content);
         // return ( $user_info ) ? htmlspecialchars( $user_info->$field ) . do_shortcode( $content ) : '';
     }
     // logout link shortcode
     if (is_user_logged_in() && $tag == 'wpmem_logout') {
         $link = $url ? wpmem_chk_qstr($url) . 'a=logout' : wpmem_chk_qstr(get_permalink()) . 'a=logout';
         $text = $content ? $content : __('Click here to log out.', 'wp-members');
         return do_shortcode("<a href=\"{$link}\">{$text}</a>");
     }
 }
Ejemplo n.º 4
0
    /**
     * Member Links Dialog.
     *
     * Outputs the links used on the members area.
     *
     * @since 2.0
     *
     * @param  string $page
     * @return string $str
     */
    function wpmem_inc_memberlinks($page = 'members')
    {
        global $user_login, $wpmem;
        $link = wpmem_chk_qstr();
        /**
         * Filter the log out link.
         *
         * @since 2.8.3
         *
         * @param string $link The default logout link.
         */
        $logout = apply_filters('wpmem_logout_link', $link . 'a=logout');
        switch ($page) {
            case 'members':
                $str = '<ul><li><a href="' . $link . 'a=edit">' . __('Edit My Information', 'wp-members') . '</a></li>
				<li><a href="' . $link . 'a=pwdchange">' . __('Change Password', 'wp-members') . '</a></li>';
                if (defined('WPMEM_EXP_MODULE') && $wpmem->use_exp == 1 && function_exists('wpmem_user_page_detail')) {
                    $str .= wpmem_user_page_detail();
                }
                $str .= '</ul>';
                /**
                 * Filter the links displayed on the User Profile page (logged in state).
                 *
                 * @since 2.8.3
                 *
                 * @param string $str The default links.
                 */
                $str = apply_filters('wpmem_member_links', $str);
                break;
            case 'register':
                $str = '<p>' . sprintf(__('You are logged in as %s', 'wp-members'), $user_login) . '</p>
			<ul>
				<li><a href="' . $logout . '">' . __('Click to log out.', 'wp-members') . '</a></li>
				<li><a href="' . get_option('home') . '">' . __('Begin using the site.', 'wp-members') . '</a></li>
			</ul>';
                /**
                 * Filter the links displayed on the Register page (logged in state).
                 *
                 * @since 2.8.3
                 *
                 * @param string $str The default links.
                 */
                $str = apply_filters('wpmem_register_links', $str);
                break;
            case 'login':
                $args = array('wrapper_before' => '<p>', 'wrapper_after' => '</p>', 'user_login' => $user_login, 'welcome' => __('You are logged in as %s', 'wp-members'), 'logout_text' => __('Click to log out', 'wp-members'), 'logout_link' => '<a href="' . $logout . '">%s</a>', 'separator' => '<br />');
                /**
                 * Filter the status message parts.
                 *
                 * @since 2.9.9
                 *
                 * @param array $args.
                 */
                $args = apply_filters('wpmem_login_links_args', $args);
                // Assemble the message string.
                $str = $args['wrapper_before'] . sprintf($args['welcome'], $args['user_login']) . $args['separator'] . sprintf($args['logout_link'], $args['logout_text']) . $args['wrapper_after'];
                /**
                 * Filter the links displayed on the Log In page (logged in state).
                 *
                 * @since 2.8.3
                 *
                 * @param string $str The default links.
                 */
                $str = apply_filters('wpmem_login_links', $str);
                break;
            case 'status':
                $args = array('wrapper_before' => '<p>', 'wrapper_after' => '</p>', 'user_login' => $user_login, 'welcome' => __('You are logged in as %s', 'wp-members'), 'logout_text' => __('click to log out', 'wp-members'), 'logout_link' => '<a href="' . $logout . '">%s</a>', 'separator' => ' | ');
                /**
                 * Filter the status message parts.
                 *
                 * @since 2.9.9
                 *
                 * @param array $args.
                 */
                $args = apply_filters('wpmem_status_msg_args', $args);
                // Assemble the message string.
                $str = $args['wrapper_before'] . sprintf($args['welcome'], $args['user_login']) . $args['separator'] . sprintf($args['logout_link'], $args['logout_text']) . $args['wrapper_after'];
                break;
        }
        return $str;
    }
Ejemplo n.º 5
0
/**
 * Redirects a user to defined login page with return redirect.
 *
 * @since 3.0.2
 */
function wpmem_redirect_to_login()
{
    global $wpmem;
    if (!is_user_logged_in() && $wpmem->is_blocked()) {
        global $post;
        // Get the page location.
        $page = urlencode("http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
        $url = wpmem_chk_qstr($wpmem->user_pages['login']) . 'redirect_to=' . $page;
        wp_redirect($url);
        exit;
    }
    return;
}
Ejemplo n.º 6
0
 /**
  * Executes various shortcodes.
  *
  * This function executes shortcodes for pages (settings, register, login, user-list,
  * and tos pages), as well as login status and field attributes when the wp-members tag
  * is used.  Also executes shortcodes for login status with the wpmem_logged_in tags
  * and fields when the wpmem_field tags are used.
  *
  * @since 2.4.0
  *
  * @global object $wpmem The WP_Members object.
  *
  * @param  array  $attr page|url|status|msg|field|id
  * @param  string $content
  * @param  string $tag
  * @return string Returns the result of wpmem_do_sc_pages|wpmem_list_users|wpmem_sc_expmessage|$content.
  */
 function wpmem_shortcode($attr, $content = null, $tag = 'wp-members')
 {
     global $wpmem;
     // Set all default attributes to false.
     $defaults = array('page' => false, 'redirect_to' => null, 'url' => false, 'status' => false, 'msg' => false, 'field' => false, 'id' => false, 'underscores' => 'off');
     // Merge defaults with $attr.
     $atts = shortcode_atts($defaults, $attr, $tag);
     // Handles the 'page' attribute.
     if ($atts['page']) {
         if ($atts['page'] == 'user-list') {
             if (function_exists('wpmem_list_users')) {
                 $content = do_shortcode(wpmem_list_users($attr, $content));
             }
         } elseif ($atts['page'] == 'tos') {
             return $atts['url'];
         } else {
             $content = do_shortcode(wpmem_do_sc_pages($atts['page'], $atts['redirect_to']));
         }
         // Resolve any texturize issues.
         if (strstr($content, '[wpmem_txt]')) {
             // Fixes the wptexturize.
             remove_filter('the_content', 'wpautop');
             remove_filter('the_content', 'wptexturize');
             add_filter('the_content', 'wpmem_texturize', 999);
         }
         return $content;
     }
     // Handles the 'status' attribute.
     if ($atts['status'] || $tag == 'wpmem_logged_in') {
         return do_shortcode(wpmem_sc_logged_in($atts, $content, $tag));
     }
     // @deprecated 3.0.0
     // Handles the wpmem_logged_out tag with no attributes & the user is not logged in.
     /*
     if ( $tag == 'wpmem_logged_out' && ( ! $attr ) && ! is_user_logged_in() ) {
     	return do_shortcode( $content );
     }
     */
     // Handles the 'field' attribute.
     if ($atts['field'] || $tag == 'wpmem_field') {
         if ($atts['id']) {
             // We are getting some other user.
             if ($atts['id'] == 'get') {
                 $the_user_ID = isset($_GET['uid']) ? $_GET['uid'] : '';
             } else {
                 $the_user_ID = $atts['id'];
             }
         } else {
             // Get the current user.
             $the_user_ID = get_current_user_id();
         }
         $user_info = get_userdata($the_user_ID);
         if ($atts['underscores'] == 'off' && $user_info) {
             $user_info->{$atts}['field'] = str_replace('_', ' ', $user_info->{$atts}['field']);
         }
         return $user_info ? htmlspecialchars($user_info->{$atts}['field']) . do_shortcode($content) : do_shortcode($content);
     }
     // Logout link shortcode.
     if (is_user_logged_in() && $tag == 'wpmem_logout') {
         $link = $atts['url'] ? wpmem_chk_qstr($atts['url']) . 'a=logout' : wpmem_chk_qstr(get_permalink()) . 'a=logout';
         $text = $content ? $content : __('Click here to log out.', 'wp-members');
         return do_shortcode("<a href=\"{$link}\">{$text}</a>");
     }
 }
Ejemplo n.º 7
0
/**
 * Redirects a user to defined login page with return redirect.
 *
 * @since 3.0.2
 *
 * @global object $wp    The WordPress object.
 * @global object $post  The WordPress post object.
 * @global object $wpmem The WP-Members object.
 */
function wpmem_redirect_to_login()
{
    global $wp, $post, $wpmem;
    if (!is_user_logged_in() && $wpmem->is_blocked()) {
        // Get current page location.
        $current_page = home_url(add_query_arg(array(), $wp->request));
        $redirect_to = urlencode($current_page);
        $url = wpmem_chk_qstr($wpmem->user_pages['login']) . 'redirect_to=' . $redirect_to;
        wp_redirect($url);
        exit;
    }
    return;
}
    /**
     * Login Form Dialog
     *
     * Builds the table-less form used for
     * login, change password, and reset password.
     *
     * @since 2.5.1
     *
     * @uses apply_filters Calls 'wpmem_login_form_before'
     * @uses apply_filters Calls 'wpmem_forgot_link'
     * @uses apply_filters Calls 'wpmem_reg_link'
     * @uses apply_filters Calls 'wpmem_login_form'
     *
     * @param  string $page
     * @param  array  $arr
     * @return string $form
     */
    function wpmem_login_form_NEW($page, $arr)
    {
        // are we redirecting somewhere?
        /*if( isset( $_REQUEST['redirect_to'] ) ) {
        		$redirect_to = $_REQUEST['redirect_to'];
        	} else {
        		$redirect_to = get_permalink();
        	}*/
        $redirect_to = isset($_REQUEST['redirect_to']) ? esc_url($_REQUEST['redirect_to']) : get_permalink();
        // fix the wptexturize
        remove_filter('the_content', 'wpautop');
        remove_filter('the_content', 'wptexturize');
        add_filter('the_content', 'wpmem_texturize', 99);
        $form = apply_filters('wpmem_login_form_before', '');
        $form .= '[wpmem_txt]<div id="wpmem_login">
		<a name="login"></a>
		<form action="' . get_permalink() . '" method="POST" class="form">
		<fieldset>
			<legend>' . $arr[0] . '</legend>
				
			<label for="username">' . $arr[1] . '</label>
			<div class="div_text">
				' . wpmem_create_formfield($arr[3], $arr[2], '', '', $arr[9]) . '
			</div>
			
			<label for="password">' . $arr[4] . '</label>
			<div class="div_text">
				' . wpmem_create_formfield($arr[6], $arr[5], '', '', $arr[10]) . '
			</div>
				
			<input type="hidden" name="redirect_to" value="' . $redirect_to . '" />';
        if ($arr[7] != 'login') {
            $form = $form . wpmem_create_formfield('formsubmit', 'hidden', '1');
        }
        $form = $form . wpmem_create_formfield('a', 'hidden', $arr[7]);
        $form = $form . '<div class="button_div">';
        if ($arr[7] == 'login') {
            $form = $form . '<input name="rememberme" type="checkbox" id="rememberme" value="forever" />&nbsp;' . __('Remember me', 'wp-members') . '&nbsp;&nbsp;<input type="submit" name="Submit" value="' . $arr[8] . '" class="buttons" />';
        } else {
            $form = $form . '<input type="submit" name="Submit" value="' . $arr[8] . '" class="buttons" />';
        }
        $form = $form . '</div>

			<div class="clear"></div>
			<div align="right">';
        if ((WPMEM_MSURL != null || $page == 'members') && $arr[7] == 'login') {
            $link = apply_filters('wpmem_forgot_link', wpmem_chk_qstr(WPMEM_MSURL) . 'a=pwdreset');
            $form = $form . __('Forgot password?', 'wp-members') . '&nbsp;<a href="' . $link . '">' . __('Click here to reset', 'wp-members') . '</a>';
        }
        $form = $form . '</div>
			<div align="right">';
        if (WPMEM_REGURL != null && $arr[7] == 'login') {
            $link = apply_filters('wpmem_reg_link', WPMEM_REGURL);
            $form = $form . __('New User?', 'wp-members') . '&nbsp;<a href="' . $link . '">' . __('Click here to register', 'wp-members') . '</a>';
        }
        $form = $form . '</div>	
			<div class="clear"></div>
		</fieldset></form>
	</div>[/wpmem_txt]';
        $form = apply_filters('wpmem_login_form', $form);
        return $form;
    }
Ejemplo n.º 9
0
    /**
     * Creates the sidebar login form and status
     *
     * This function determines if the user is logged in
     * and displays either a login form, or the user's 
     * login status. Typically used for a sidebar.		
     * You can call this directly, or with the widget
     *
     * @since 2.4
     *
     * @uses apply_filters Calls 'wpmem_sidebar_form'
     * @uses apply_filters Calls 'wpmem_sidebar_status'
     * @uses apply_filters Calls 'wpmem_login_failed_sb'
     * @uses apply_filters Calls 'wpmem_forgot_link'
     * @uses apply_filters Calls 'wpmem_reg_link'
     *
     * @global string $wpmem_regchk
     * @global string $user_login
     */
    function wpmem_do_sidebar()
    {
        global $wpmem_regchk;
        $url = get_bloginfo('url');
        // used here and in the logout
        //this returns us to the right place
        if (isset($_REQUEST['redirect_to'])) {
            $post_to = $_REQUEST['redirect_to'];
        } elseif (is_home() || is_front_page()) {
            $post_to = $_SERVER['PHP_SELF'];
        } elseif (is_single() || is_page()) {
            $post_to = get_permalink();
        } elseif (is_category()) {
            global $wp_query;
            $cat_id = get_query_var('cat');
            $post_to = get_category_link($cat_id);
        } elseif (is_search()) {
            $post_to = $url . '/?s=' . get_search_query();
        } else {
            $post_to = $_SERVER['PHP_SELF'];
        }
        // clean whatever the url is
        $post_to = esc_url($post_to);
        if (!is_user_logged_in()) {
            if (WPMEM_OLD_FORMS == 1) {
                include_once 'wp-members-deprecated.php';
                wpmem_old_forms_sidebar($post_to);
            } else {
                $str = '';
                if ($wpmem_regchk == 'loginfailed' && $_POST['slog'] == 'true') {
                    $str = '<p class="err">' . __('Login Failed!<br />You entered an invalid username or password.', 'wp-members') . '</p>';
                    $str = apply_filters('wpmem_login_failed_sb', $str);
                }
                $str .= __('You are not currently logged in.', 'wp-members') . '<br />
			<fieldset>
				<form name="form" method="post" action="' . $post_to . '">
				
					<label for="username">' . __('Username', 'wp-members') . '</label>
					<div class="div_texbox"><input type="text" name="log" class="username" id="username" /></div>
					<label for="password">' . __('Password', 'wp-members') . '</label>
					<div class="div_texbox"><input type="password" name="pwd" class="password" id="password" /></div>
					<input type="hidden" name="rememberme" value="forever" />
					<input type="hidden" name="redirect_to" value="' . $post_to . '" />
					<input type="hidden" name="a" value="login" />
					<input type="hidden" name="slog" value="true" />
					<div class="button_div"><input type="submit" name="Submit" class="buttons" value="' . __('login', 'wp-members') . '" />';
                if (WPMEM_MSURL != null) {
                    $link = apply_filters('wpmem_forgot_link', wpmem_chk_qstr(WPMEM_MSURL) . 'a=pwdreset');
                    $str .= ' <a href="' . $link . '">' . __('Forgot?', 'wp-members') . '</a>&nbsp;';
                }
                if (WPMEM_REGURL != null) {
                    $link = apply_filters('wpmem_reg_link', WPMEM_REGURL);
                    $str .= ' <a href="' . $link . '">' . __('Register', 'wp-members') . '</a>';
                }
                $str .= '</div>
				</form>
			</fieldset>';
                $str = apply_filters('wpmem_sidebar_form', $str);
                echo $str;
            }
        } else {
            global $user_login;
            $logout = $url . '/?a=logout';
            $str = '<p>' . sprintf(__('You are logged in as %s', 'wp-members'), $user_login) . '<br />
		  <a href="' . $logout . '">' . __('click here to logout', 'wp-members') . '</a></p>';
            $str = apply_filters('wpmem_sidebar_status', $str);
            echo $str;
        }
    }
Ejemplo n.º 10
0
 /**
  * Creates the sidebar login form and status.
  *
  * This function determines if the user is logged in and displays either
  * a login form, or the user's login status. Typically used for a sidebar.		
  * You can call this directly, or with the widget.
  *
  * @since 2.4
  *
  * @param  string $post_to      A URL to redirect to upon login, default null.
  * @global string $wpmem_regchk
  * @global string $user_login
  */
 function wpmem_do_sidebar($post_to = null)
 {
     global $wpmem_regchk;
     $url = get_bloginfo('url');
     // used here and in the logout
     $post_to = $_SERVER['REQUEST_URI'];
     // clean whatever the url is
     $post_to = esc_url($post_to);
     if (!is_user_logged_in()) {
         // if the user is not logged in, we need the form
         // defaults
         $defaults = array('error_before' => '<p class="err">', 'error_after' => '</p>', 'fieldset_before' => '<fieldset>', 'fieldset_after' => '</fieldset>', 'inputs_before' => '<div class="div_texbox">', 'inputs_after' => '</div>', 'buttons_before' => '<div>', 'buttons_after' => '</div>', 'error_msg' => __('Login Failed!<br />You entered an invalid username or password.', 'wp-members'), 'status_msg' => __('You are not logged in.', 'wp-members') . '<br />', 'strip_breaks' => true, 'wrap_inputs' => true, 'n' => "\n", 't' => "\t");
         /**
          * Filter arguments for the sidebar defaults.
          *
          * @since 2.9.0
          *
          * @param array An array of the defaults to be changed.
          */
         $args = apply_filters('wpmem_sb_login_args', '');
         // merge $args with defaults and extract
         extract(wp_parse_args($args, $defaults));
         $form = '';
         $focus1 = "if (this.value == 'VU-net-ID') {this.value = '';}";
         $blur1 = "if (this.value == '') {this.value = 'VU-net-ID';}";
         $focus2 = "if (this.value == 'Wachtwoord') {this.value = '';}";
         $blur2 = "if (this.value == '') {this.value = 'Wachtwoord';}";
         $label = '<span class="add-on" style="float: left;"><i class="icon-user"></i></span>';
         $input = '<input type="text" name="log" class="username" id="username" value="VU-net-ID" style="margin-top: -10px;" onfocus="' . $focus1 . '" onblur="' . $blur1 . '" />';
         $input = $wrap_inputs ? $inputs_before . $input . $inputs_after : $input;
         $row1 = $label . $n . $input . $n;
         $label = '<span class="add-on" style="float: left;"><i class="icon-lock"></i></span>';
         $input = '<input type="password" name="pwd" class="password" id="password" value="Wachtwoord" style="margin-top: -10px;" onfocus="' . $focus2 . '" onblur="' . $blur2 . '" />';
         $input = $wrap_inputs ? $inputs_before . $input . $inputs_after : $input;
         $row2 = $label . $n . $input . $n;
         $form = $row1 . $row2;
         $hidden = '<input type="hidden" name="rememberme" value="forever" />' . $n . '<input type="hidden" name="redirect_to" value="' . $post_to . '" />' . $n . '<input type="hidden" name="a" value="login" />' . $n . '<input type="hidden" name="slog" value="true" />';
         /**
          * Filter sidebar login form hidden fields.
          *
          * @since 2.9.0
          *
          * @param string $hidden The HTML for the hidden fields.
          */
         $form = $form . apply_filters('wpmem_sb_hidden_fields', $hidden);
         $buttons = '<input type="submit" name="Submit" class="wpcf7-submit" style="margin-right: 5px;" value="' . __('log in', 'wp-members') . '" />';
         if (WPMEM_MSURL != null) {
             /**
              * Filter the sidebar forgot password link.
              *
              * @since 2.8.0
              *
              * @param string The forgot password link.
              */
             $link = apply_filters('wpmem_forgot_link', wpmem_chk_qstr(WPMEM_MSURL) . 'a=pwdreset');
             $buttons .= ' <a href="' . $link . '">' . __('Forgot?', 'wp-members') . '</a>&nbsp;';
         }
         if (WPMEM_REGURL != null) {
             /**
              * Filter the sidebar register link.
              *
              * @since 2.8.0
              *
              * @param string The register link.
              */
             $link = apply_filters('wpmem_reg_link', WPMEM_REGURL);
             $buttons .= ' <a href="' . $link . '">' . __('Register') . '</a>';
         }
         $form = $form . $n . $buttons_before . $buttons . $n . $buttons_after;
         $form = $fieldset_before . $n . $form . $n . $fieldset_after;
         $form = '<form name="form" method="post" action="' . $post_to . '">' . $n . $form . $n . '</form>';
         // add status message
         $form = $status_msg . $n . $form;
         // strip breaks
         $form = $strip_breaks ? str_replace(array("\n", "\r", "\t"), array('', '', ''), $form) : $form;
         /**
          * Filter the sidebar form.
          *
          * @since ?.?
          *
          * @param string $form The HTML for the sidebar login form.
          */
         $form = apply_filters('wpmem_sidebar_form', $form);
         $do_error_msg = '';
         if (isset($_POST['slog']) && $wpmem_regchk == 'loginfailed') {
             $do_error_msg = true;
             $error_msg = $error_before . $error_msg . $error_after;
             /**
              * Filter the sidebar login failed message.
              *
              * @since ?.?
              *
              * @param string $error_msg The error message.
              */
             $error_msg = apply_filters('wpmem_login_failed_sb', $error_msg);
         }
         $form = $do_error_msg ? $error_msg . $form : $form;
         echo $form;
     } else {
         global $user_login;
         /**
          * Filter the sidebar logout link.
          *
          * @since ?.?
          *
          * @param string The logout link.
          */
         global $current_user;
         get_currentuserinfo();
         $logout = apply_filters('wpmem_logout_link', $url . '/?a=logout');
         $password = apply_filters('wpmem_forgot_link', $url . '/leden/?a=pwdchange');
         $str = '<h1 style="font-size: 22px; font-weight: normal;">Hoi, <b>' . sprintf(__($current_user->user_firstname, 'wp-members'), $user_login) . '</b>!</h1>
   <a href="' . $logout . '" style="font-size: 16px; float: right; margin-top: -71px; background: -webkit-linear-gradient(top, #e05d22 0%, #d94412 100%);background: linear-gradient(to bottom, #e05d22 0%, #d94412 100%);border: none;border-bottom: 3px solid #b93207;border-radius: 2px;color: #fff;display: inline-block;padding: 11px 24px 10px;text-decoration: none;">Afmelden</a>
   <h1 style="font-size: 11px; font-weight: normal; padding: 0 0 0 10px; margin-top:-10px">Klik <a href="' . $password . '" style="font-weight: bold;">hier</a> om je wachtwoord te veranderen.</h1>';
         /**
          * Filter the sidebar user login status.
          *
          * @since ?.?
          *
          * @param string $str The login status for the user.
          */
         $str = apply_filters('wpmem_sidebar_status', $str);
         echo $str;
     }
 }
/**
 * Old form sidebar login
 *
 * @since 2.8.0
 *
 * @param string $post_to
 */
function wpmem_old_forms_sidebar($post_to)
{
    ?>
	<ul>
	<?php 
    if ($wpmem_regchk == 'loginfailed' && $_POST['slog'] == 'true') {
        ?>
		<p><?php 
        _e('Login Failed!<br />You entered an invalid username or password.', 'wp-members');
        ?>
</p>
	<?php 
    }
    ?>
		<p><?php 
    _e('You are not currently logged in.', 'wp-members');
    ?>
<br />
			<form name="form" method="post" action="<?php 
    echo $post_to;
    ?>
">
			<?php 
    _e('Username', 'wp-members');
    ?>
<br />
			<input type="text" name="log" style="font:10px verdana,sans-serif;" /><br />
			<?php 
    _e('Password', 'wp-members');
    ?>
<br />
			<input type="password" name="pwd" style="font:10px verdana,sans-serif;" /><br />
			<input type="hidden" name="rememberme" value="forever" />
			<input type="hidden" name="redirect_to" value="<?php 
    echo $post_to;
    ?>
" />
			<input type="hidden" name="a" value="login" />
			<input type="hidden" name="slog" value="true" />
			<input type="submit" name="Submit" value="<?php 
    _e('login', 'wp-members');
    ?>
" style="font:10px verdana,sans-serif;" />
			<?php 
    if (WPMEM_MSURL != null) {
        $link = wpmem_chk_qstr(WPMEM_MSURL);
        ?>
					<a href="<?php 
        echo $link;
        ?>
a=pwdreset"><?php 
        _e('Forgot?', 'wp-members');
        ?>
</a>&nbsp;
				<?php 
    }
    if (WPMEM_REGURL != null) {
        ?>
					<a href="<?php 
        echo WPMEM_REGURL;
        ?>
"><?php 
        _e('Register', 'wp-members');
        ?>
</a>

				<?php 
    }
    ?>
			</form>
		</p>
	</ul>
<?php 
}
    /**
     * Member Links Dialog
     *
     * Outputs the links used on the members area.
     *
     * @since 2.0
     *
     * @param  string $page
     * @return string $str
     */
    function wpmem_inc_memberlinks($page = 'members')
    {
        global $user_login;
        $link = wpmem_chk_qstr();
        /**
         * Filter the log out link.
         *
         * @since 2.8.3
         *
         * @param string $link The default logout link.
         */
        $logout = apply_filters('wpmem_logout_link', $link . 'a=logout');
        switch ($page) {
            case 'members':
                $str = '<ul><li><a href="' . $link . 'a=edit">' . __('Edit My Information', 'wp-members') . '</a></li>
				<li><a href="' . $link . 'a=pwdchange">' . __('Change Password', 'wp-members') . '</a></li>';
                if (WPMEM_USE_EXP == 1 && function_exists('wpmem_user_page_detail')) {
                    $str .= wpmem_user_page_detail();
                }
                $str .= '</ul>';
                /**
                 * Filter the links displayed on the User Profile page (logged in state).
                 *
                 * @since 2.8.3
                 *
                 * @param string $str The default links.
                 */
                $str = apply_filters('wpmem_member_links', $str);
                break;
            case 'register':
                $str = '<p>' . sprintf(__('You are logged in as %s', 'wp-members'), $user_login) . '</p>
			<ul>
				<li><a href="' . $logout . '">' . __('Click to log out.', 'wp-members') . '</a></li>
				<li><a href="' . get_option('home') . '">' . __('Begin using the site.', 'wp-members') . '</a></li>
			</ul>';
                /**
                 * Filter the links displayed on the Register page (logged in state).
                 *
                 * @since 2.8.3
                 *
                 * @param string $str The default links.
                 */
                $str = apply_filters('wpmem_register_links', $str);
                break;
            case 'login':
                $str = '<p>
		  	' . sprintf(__('You are logged in as %s', 'wp-members'), $user_login) . '<br />
		  	<a href="' . $logout . '">' . __('Click to log out', 'wp-members') . '</a>
			</p>';
                /**
                 * Filter the links displayed on the Log In page (logged in state).
                 *
                 * @since 2.8.3
                 *
                 * @param string $str The default links.
                 */
                $str = apply_filters('wpmem_login_links', $str);
                break;
            case 'status':
                $str = '<p>
			' . sprintf(__('You are logged in as %s', 'wp-members'), $user_login) . '  | 
			<a href="' . $logout . '">' . __('click to log out', 'wp-members') . '</a>
			</p>';
                break;
        }
        return $str;
    }
Ejemplo n.º 13
0
    /**
     * Member Links Dialog
     *
     * Outputs the links used on the members area.
     *
     * @since 2.0
     *
     * @uses apply_filters Calls 'wpmem_member_links'
     * @uses apply_filters Calls 'wpmem_register_links'
     * @uses apply_filters Calls 'wpmem_login_links'
     *
     * @param  string $page
     * @return string $str
     */
    function wpmem_inc_memberlinks($page = 'members')
    {
        global $user_login;
        $link = wpmem_chk_qstr();
        switch ($page) {
            case 'members':
                $str = '<ul><li><a href="' . $link . 'a=edit">' . __('Edit My Information', 'wp-members') . '</a></li>
				<li><a href="' . $link . 'a=pwdchange">' . __('Change Password', 'wp-members') . '</a></li>';
                if (WPMEM_USE_EXP == 1) {
                    $str .= wpmem_user_page_detail();
                }
                $str .= '</ul>';
                $str = apply_filters('wpmem_member_links', $str);
                break;
            case 'register':
                // $str = '<p>' . sprintf( __( 'You are logged in as %s', 'wp-members' ), $user_login ) . '</p>
                // 	<ul>
                // 		<li><a href="' . $link . 'a=logout">' . __( 'Click here to logout.', 'wp-members' ) . '</a></li>
                // 		<li><a href="' . get_option('siteurl') . '">' . __( 'Begin using the site.', 'wp-members' ) . '</a></li>
                // 	</ul>';
                // $str = apply_filters( 'wpmem_register_links', $str );
                wp_safe_redirect("/");
                break;
            case 'login':
                // $str = '<p>
                //   	' . sprintf( __( 'You are logged in as %s', 'wp-members' ), $user_login ) . '<br />
                //   	<a href="' . $link . 'a=logout">' . __( 'click here to logout', 'wp-members' ) . '</a>
                // 	</p>';
                // $str = apply_filters( 'wpmem_login_links', $str );
                // break;
                wp_safe_redirect("/");
            case 'status':
                $str = '<p>
			' . sprintf(__('You are logged in as %s', 'wp-members'), $user_login) . '  | 
			<a href="' . $link . 'a=logout">' . __('click here to logout', 'wp-members') . '</a>
			</p>';
                break;
        }
        return $str;
    }