Community Support Forums — WordPress® ( Users Helping Users ) — 2010-10-27T08:30:00-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=1097 2010-10-27T08:30:00-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1097&p=4303#p4303 <![CDATA[Re: Login redirection broken for users with Author capabilit]]>
I had already been taking a look at that line in the \wp-content\plugins\s2member\includes\functions\login-redirection.inc.php file, but I hadn't been able to figure out what the right edit to the check was.

Curiously, the check that did the trick was the opposite one:
Code:
if !$user->has_cap ("author")


Maybe because my users are not "proper" Authors, but Subscribers and s2-level-1 members with added capabilities that give them author rights. I'm not sure I understand :? , but it sure is working! Both Subscribers and s2-level-1 members now get redirected to my custom Welcome page, so I can gratefully mark this issue as:

RESOLVED.

Thanks again! :D

Statistics: Posted by arwyl — October 27th, 2010, 8:30 am


]]>
2010-10-27T03:41:44-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1097&p=4284#p4284 <![CDATA[Re: Login redirection broken for users with Author capabilit]]> Thanks for the excellent question.

Well, I wish we had a Hook/Filter that would accomplish this for you. I'll see about adding a Filter in the next release so the method I'm about to describe won't be necessary. Until then, here goes.

Unzip the file that I've attached, and place it into your /mu-plugins/ directory. If you don't have an /mu-plugins/ directory, please create one. MUST USE (mu)-plugins are loaded automatically.

s2-login-redirection.zip
I've added this additional check: $user->has_cap("author")
Code:
<?php
/*
Create this function before s2Member loads it's default version.
    goes here: /wp-content/mu-plugins/s2-login-redirection.php
*/
function ws_plugin__s2member_login_redirect ($username = FALSE)
    {
        eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
        do_action ("ws_plugin__s2member_before_login_redirect", get_defined_vars ());
        unset ($__refs, $__v); /* Unset defined __refs, __v. */
        /**/
        $username = (!$username && is_object ($current_user = wp_get_current_user ())) ? $current_user->user_login : $username;
        /* This additional check was added in case wp_signon() fires this event with empty $_POST credentials.
            In this rare case, we can check to see if WordPress® is remembering a previously logged in User. */
        /**/
        if (!is_object ($user = new WP_User ($username)) || ! ($user_id = $user->ID) || !$user->has_cap ("edit_posts") || $user->has_cap ("author"))
            {
                eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                do_action ("ws_plugin__s2member_during_login_redirect", get_defined_vars ());
                unset ($__refs, $__v); /* Unset defined __refs, __v. */
                /**/
                if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"] && function_exists ("ws_plugin__s2member_generate_password"))
                    {
                        delete_user_setting ("default_password_nag"); /* setcookie() */
                        update_user_option ($user_id, "default_password_nag", false, true);
                    }
                /**/
                if (strtolower ($username) === "demo" || ws_plugin__s2member_ip_restrictions_ok ($_SERVER["REMOTE_ADDR"], strtolower ($username)))
                    {
                        if ($special_redirection_url = ws_plugin__s2member_login_redirection_url ($user))
                            wp_redirect ($special_redirection_url);
                        /**/
                        else
                            wp_redirect 
(get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
                    }
                /**/
                exit ();
            }
        /**/
        eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
        do_action ("ws_plugin__s2member_after_login_redirect", get_defined_vars ());
        unset ($__refs, $__v); /* Unset defined __refs, __v. */
        /**/
        return;
    }
?>

Statistics: Posted by Jason Caldwell — October 27th, 2010, 3:41 am


]]>
2010-10-26T18:24:25-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1097&p=4256#p4256 <![CDATA[Login redirection broken for users with Author capabilities]]>
Thanks very much in advance!

Statistics: Posted by arwyl — October 26th, 2010, 6:24 pm


]]>