0

I'm making an ExpressionEngine extension that is supposed to return to a certain URL after the user logged in. I'm using this hook: member_member_login_single. This returns me to the right url, but it doesn't finish the whole login process. In other words: it's not logging my user in! How am I supposed to do this? There doesn't seem to be a hook like member_login_end.

 function activate_extension()
{
    $this->settings = array(
        'prijs_per_kind'    => 5,
        'sluitingsdatum'    => '05-11-2016',
    );

    $hooks = array(
            "zoo_visitor_register_end" => "redirectToPayment",
            "member_member_login_single" => "checkClosingDate"
    );

    foreach ($hooks as $hook => $method) {
        $data = array(
                'class' => __CLASS__,
                'method' => $method,
                'hook' => $hook,
                'settings' => serialize($this->settings),
                'priority' => 10,
                'version' => $this->version,
                'enabled' => 'y'
        );
    }
    ee()->db->insert('extensions', $data);
}

function checkClosingDate()
{

        ee()->functions->redirect('http://sportvandemaand.local/account/profiel/verlopen');

}

2 Answers 2

1

Well, you are killing the process when you throw a redirect. The redirect() function basically causes a die() affect, ending code termination.

You know you can declare a redirect in the template with the log-in form?

http://ee2docs.com/add-ons/member/index.html#login-form-tag

You just add a return="your_url" parameter to the tag.

{exp:member:login_form return="your_url"}

    Form stuff here, see reference

{/exp:member:login_form}
0

If for some reason you really do need to set the redirect inside of your hook (perhaps, for example, you're performing some additional logic inside your method which you've excised for simplicity), try manually setting the value of $_POST['RET'] inside your method.

$_POST['RET'] = 'account/profiel/verlopen';

This value will get processed inside of Functions::form_backtrack(), which is called by Member_auth::_build_success_message(), which is the last step of Member_auth:member_login().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.