• Resolved benz_admin

    (@benz_admin)


    Hi guys,
    I found some istructions about it but I didn’t solve.

    I created the file theme-my-login-custom.php and moved it on /wp-content/plugins/.

    PHP content is:

    <?php
    function tml_new_user_registered( $user_id ) {
        wp_set_auth_cookie( $user_id, false, is_ssl() );
        wp_redirect( 'http://www.mysiste.com/area-privata' );
        exit;
    }
    add_action( 'tml_new_user_registered', 'tml_new_user_registered' );
    ?>

    But it doesn’t work.
    Can anyone help me please?

    https://wordpress.org/plugins/theme-my-login/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jeff Farthing

    (@jfarthing84)

    That action no longer exists. Use register_new_user instead.

    Thread Starter benz_admin

    (@benz_admin)

    thanks for your reply Jeff,
    I try to insert this code

    <?php
    function register_new_user( $user_id ) {
        wp_set_auth_cookie( $user_id, false, is_ssl() );
        wp_redirect( 'http://www.leinontirovina.com/area-privata' );
        exit;
    }
    add_action( 'register_new_user', 'register_new_user' );
    ?>

    but it shows me this error
    “Fatal error: Cannot redeclare register_new_user() (previously declared in ********/wp-includes/user.php:2212) in *****/wp-content/plugins/theme-my-login-custom.php on line 2

    What’s wrong?

    Thread Starter benz_admin

    (@benz_admin)

    Ok. I solved it.

    For everyone will have the same problem on WP 4.5.1. this is the the correct way:

    create the file theme-my-login-custom.php
    code to insert

    <?php
    function auto_login_new_user( $user_id ) {
            wp_set_current_user($user_id);
            wp_set_auth_cookie($user_id);
            wp_redirect( 'http://www.example.com/' );
            exit;
        }
        add_action( 'user_register', 'auto_login_new_user' );
    ?>

    upload it on /wp-content/plugins/

    Hello, your function works however stopped sending e-mail with the confirmation registration for user and admin

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Add your custom function to a higher priority:

    add_action( 'user_register', 'auto_login_new_user', 15 );

    I also wanted to auto log in the user upon registration, and encountered the same problem, that the email confirmations broke. So I added one line of code that made the email confirmations work (see 5th line):

    <?php
    function auto_login_new_user( $user_id ) {
            wp_set_current_user($user_id);
            wp_set_auth_cookie($user_id);
            wp_new_user_notification( $user_id, null, 'both' );
            wp_redirect( 'http://www.example.com' );
            exit;
        }
        add_action( 'user_register', 'auto_login_new_user' );
    ?>

    HOWEVER, now the email notifications are coming from the default WP setting, NOT the TML custom emails. How can I send the TML emails?

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Did you see the last thing I said in this thread? 😉

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Auto login % redirect after registration’ is closed to new replies.