0

I am currently using the wp_login hook to run a php function when a user logins. However, I want to show users who login notifications (a pop up with recent posts, etc) and I was planning to do this by running a javascript function.

Is it possible to edit the page shown to the user after login?

This is the code I have so far:

add_action( 'wp_login', 'my_login_function' );
add_action( 'wp_footer', 'the_footer_function' );

function the_footer_function(){
    if (defined('FIRST_RUN')){
        echo "<script>jQuery(document).ready( function(){alert('hello');});</script>";
        define('FIRST_RUN', false);
    }
}

function my_login_function($user_login){
     global $altdb;
     $user_info = get_userdatabylogin($user_login);
     $wonAwards = $altdb->get_var("SELECT achievement_id FROM user_".$user_info->ID." WHERE isTold='false'");
     define('FIRST_RUN', true);
     //$altdb->query("UPDATE user_".$user_info->ID." SET isTold='true' WHERE isTold = false") or die(mysql_error());
}

Any help is appreciated.

2
add_filter( "login_redirect", "my_login_redirect", 10, 3 );
function my_login_redirect( $redirect_to, $request, $user )
{
    return home_url( "/your_page/" );
}

Should about do it for you. Modified from a script that I had running in wp3.3.1.

Docs: home_url(), login_redirect

0

you may try using the wp_redirect() function, I was doing that in the past but I don't know how it will behave in the recent releases (in theory it should work)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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