4

I've tried everything: Peter's Login Redirect, Redirection, some unworking javascript hacks, routemap PHP Class (which is really impressive, but I'm not sure that's very useful in this case).

I'm using Theme My Login, but its redirection settings just wouldn't respond. (Still need it, though).

Any ideas?

  • This may be because of a plugin incompatibility. I found that I couldn't get the redirection feature to work when I had the plugin "bbPress" activated. Deactivate all the rest of your plugins, then activate them one by one to determine the culprit. – user18275 Jul 17 '12 at 23:24
8

You can use the WordPress function wp_redirect(). If you want a redirect after login or logout, check the plugin Adminimize, it has an option for this.

Two examples for a redirect in a custom plugin or functions.php of the theme (the following example uses the variable $pagenow):

function fb_redirect_1() {
    global $pagenow;

    if ( 'plugins.php' === $pagenow ) {
        if ( function_exists('admin_url') ) {
            wp_redirect( admin_url('edit-comments.php') );
        } else {
            wp_redirect( get_option('siteurl') . '/wp-admin/' . 'edit-comments.php' );
        }
    }
}
if ( is_admin() )
    add_action( 'admin_menu', 'fb_redirect_1' );

An alternative with $_server, checks the URL too:

function fb_redirect_2() {

    if ( preg_match('#wp-admin/?(index.php)?$#', $_SERVER['REQUEST_URI']) ) {
        if ( function_exists('admin_url') ) {
            wp_redirect( admin_url('edit-comments.php') );
        } else {
            wp_redirect( get_option('siteurl') . '/wp-admin/' . 'edit-comments.php' );
        }
    }
}
if ( is_admin() )
    add_action( 'admin_menu', 'fb_redirect_2' );
  • Yep. Finally ended up with something just like this. Thanks a lot! – konzepz Nov 17 '10 at 12:43

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.