Support » Plugin: Login with Vipps » Custom redirect url after login

  • Hi, intead of having to edit the core files. Is there a simple way to have a spesific url after completed login? With woocommerce active it just redirects to account page.

    Maybe a simple function filter?

    Thanx! 🙂
    Marius

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor iverok

    (@iverok)

    Yes, there are several ways. First, the WooCommerce login and the “ordinary” login (on wp-login.php) are actually two different functions, so they behave slightly differently.

    For WooCommerce logins you can just use the filter

    apply_filters('login_with_vipps_woo_login_redirect', $link, $user, $session);

    Your second argument here is the WC_User object so you can redirect different users to different places; the $session is an array with the raw data sent from Vipps.

    For logins on the wp-login.php page, only the standard WP ‘login_redirect’ filter is used, which normally redirects to the users profile page. However, just before this is called, an action

    do_action('continue_with_vipps_before_user_login', $user, $session);

    – is run, and if this has been run (did_action('continue_with_vipps_before_user_login');) you know this is a Vipps login if you want to treat those differently. You can also use this hook to modify the login_redirect filter directly, which is what the Woo login does.

    You can also just use the standard login_redirect filter with a very late priority if you don’t care how they log in.

    Error logins are handled completely differently, because of how the error messages need to be propagated. For woocommerce the standard rules should work ok, but if you need to handle this specially too, there are filters for this also.

    Thank you for your answer! Was able to make two different redirects now based on normal login and woocommerce login.

    Kind regards
    Marius

    • This reply was modified 1 month, 4 weeks ago by djeshm.
    • This reply was modified 1 month, 4 weeks ago by djeshm.
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.