Support » Plugins » Hack: Redirect users to the main page and/or profile

  • I love WP but it irritates the heck out of me that when a user (subscriber role) logs in, he gets taken to the dashboard (which is useless for subscribers) and the only option he can click on is “Profile”.

    First, (thanks to Whooami) I modified a bit of code that redirects users to the main page after logging in by changing a bit of code in wp-login.php

    case 'login' :
    	if ( isset( $_REQUEST['redirect_to'] ) )
    		$redirect_to = $_REQUEST['redirect_to'];
    		$redirect_to = '/blogname'; (instead of 'wp-admin/')

    Second, when the user would click on Site Admin, he would be taken to the Dashboard but I wanted the link to redirect to the user’s Profile, so I experimented and modified the following line:

    In /wp-includes/general-template.php:

    Find: (around line 52)
    $link = $before . '<a href="' . get_option('siteurl') . '/wp-admin/">' . __('Site Admin') . '</a>'*/ . $after;

    Change to:
    $link = $before . '<a href="' . get_option('siteurl') . '/wp-admin/profile.php">' . __('My Profile') . '</a>' . $after;

    This eliminates the Site Admin link to replace it with My Profile and redirects to the user’s profile page. The dasboard link is still accessible from the profile page but this is less confusing for users. When Admin clicks on the My Profile link, he gets the full backend but is in the profile page instead of the dashboard.

    Now, my “Meta” section shows the following for logged in users:

    My Profile
    Log Out
    Entries RSS
    Comments RSS

    This might not be the best solution but it works for me. If some savvy coder can come up with something better (maybe a plugin and wouldn’t show the dashboard link for level 0 users), that would be great!


Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Hack: Redirect users to the main page and/or profile’ is closed to new replies.