• Hello trying to find a way to after registration redirect to the referer.

    Currently I have two buttons, login, and register. If you use login, after login it will redirect them back to the page they were previously on.

    If you use the register, it redirects them to the login, and then after logging in it redirects them back to the home page. How and where can I change this?

    I tried to use

    <?php
    add_action('ws_plugin__s2member_during_configure_user_registration', 's2_auto_login_after_registration');
    function s2_auto_login_after_registration($vars = array()) {
        if (!is_admin() && $vars['processed'] === 'yes') {
            wp_new_user_notification($vars['user_id'], $vars['pass']);
            wp_set_auth_cookie($vars['user_id'], false, is_ssl());
            wp_redirect( wp_get_referer() );
            exit();
        }
    }
    ?>

    From http://www.primothemes.com/forums/viewtopic.php?f=4&t=14211#p31548 but this isn’t doing anything. It still redirects me the login, this bit of code was said to auto login after registration, and redirect to the page specified etc. Even if I set a page like

    <?php
    add_action('ws_plugin__s2member_during_configure_user_registration', 's2_auto_login_after_registration');
    function s2_auto_login_after_registration($vars = array()) {
        if (!is_admin() && $vars['processed'] === 'yes') {
            wp_new_user_notification($vars['user_id'], $vars['pass']);
            wp_set_auth_cookie($vars['user_id'], false, is_ssl());
            wp_redirect(S2MEMBER_LOGIN_WELCOME_PAGE_URL . '?first');
            exit();
        }
    }
    ?>

    It still does nothing.

    https://wordpress.org/plugins/s2member/

Viewing 1 replies (of 1 total)
  • Thread Starter bowenac

    (@bowenac)

    Ok I figured out a way to do it. Much simpler.

    add_filter( 'registration_redirect', 'custom_sub_registration_redirect' );
    function custom_sub_registration_redirect( $redirect ) {
        if( isset( $_SERVER['HTTP_REFERER'] ) && 0 != strlen( $_SERVER['HTTP_REFERER'] ) ) {
        	$redirect = wp_login_url(esc_url( $_SERVER['HTTP_REFERER'] ));
            //$redirect = esc_url( $_SERVER['HTTP_REFERER'] );
        }
        return $redirect;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘redirect registration to referer like login does?’ is closed to new replies.