• Resolved bogdanvrg

    (@bogdanvrg)


    Hello!

    First I want to mention that I love this plugin for it’s simplicity. Thanks a lot, we all should give you a beer :D!

    I have a problem, the only one i encountered. I want to redirect users on their first login to a specific page and after, on other logins on homepage, profile whatsoever. I found this code :

    function function_new_user($user_id) {
    add_user_meta( $user_id, ‘_new_user’, ‘1’ );
    }
    add_action( ‘user_register’, ‘function_new_user’);

    The next function will check if it’s the first login and redirect the user.

    function function_check_login_redirect($user_login, $user) {
    $logincontrol = get_user_meta($user->ID, ‘_new_user’, ‘TRUE’);
    if ( $logincontrol ) {
    //set the user to old
    update_user_meta( $user->ID, ‘_new_user’, ‘0’ );

    //Do the redirects or whatever you need to do for the first login
    wp_redirect( ‘http://www.example.com’, 302 ); exit;
    }
    }
    add_action(‘wp_login’, ‘function_check_login_redirect’, 10, 2);

    It works only with default wordpress login. What should I modify in order for it to work with clean login? Can you do it for me? Is there any alternative for this piece of code (if it isn’t good)?

    Thanks a lot !!!!

Viewing 1 replies (of 1 total)
  • Plugin Author Alberto Hornero

    (@hornero)

    I do not recommend to modify the plugin since when we update it you are going to lose the changes. I recommend you to use the filters and then override them from another plugin (made by you or someone) or include it in the functions.php file (from the theme)

    You can use both filters: cl_login_redirect_url and cl_logout_redirect_url

    Regards,

    Alberto.

Viewing 1 replies (of 1 total)

The topic ‘First Login Redirection’ is closed to new replies.