Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

1 Answer

up vote 8 down vote accepted

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' );
share|improve this answer
    
Yep. Finally ended up with something just like this. Thanks a lot! –  konzepz Nov 17 '10 at 12:43
add comment

Your Answer

 
discard

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.