ThemeShaper Forums » Development Talk

[closed]

WP Filter: login_redirect

(3 posts)
  • Started 12 years ago by iCristiano
  • Latest reply from helgatheviking
  1. iCristiano
    Member

    Hi friends, I know its not an exactly Thematic topic, but like thematic functions with filters, I think I can find help here, and the topic could be interesting for everybody...

    I trying to change the default admin page... I mean, when somebody makes a login, by default he is redirected to Dashboard or profile.php... I want to change it.

    I found on the wp-login.php on line 536 (wp version 3.0.1) a filter called login_redirect that I think is the place to touch to change it. But I´m not doing it well.

    The code there is:

    $redirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user);

    I whote it on my functions.php:

    function admin_default_page() {
      $redirect_to = 'http://www.myweb.com.br/wp-admin/post-new.php?post_type=artigo';
    }
    add_filter('login_redirect', 'admin_default_page');

    Any help ???
    Thanks!

    Posted 12 years ago #
  2. subscribe

    Posted 12 years ago #
  3. neat find. wish i had seen it sooner. the OP forgot to return a value to the filter so nothing ever happened. when using add_filter you must always return something.

    function admin_default_page() {
      $redirect_to = admin_url() . 'post-new.php?post_type=artigo';
      return $redirect_to;
    }
    add_filter('login_redirect', 'admin_default_page');
    Posted 12 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.