WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 2 down vote accepted
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

share|improve this answer

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)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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