WordPress.org

Ready to get started?Download WordPress

Forums

Hack: Redirect users to the main page and/or profile (5 posts)

  1. raygene
    Member
    Posted 6 years ago #

    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' :
    default:
    	if ( isset( $_REQUEST['redirect_to'] ) )
    		$redirect_to = $_REQUEST['redirect_to'];
    	else
    		$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
    Wordpress.org

    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!

    Cheers,
    Gene

  2. StrangeAttractor
    Member
    Posted 6 years ago #

    This is a nice hack, but there's also a plugin I've used for this (hasn't been updated in a long time, not sure if works with 2.5:

    http://wordpress.org/extend/plugins/weasels-login-redirection/

    I've used that in combination with

    http://www.jameskelly.org/wordpress-plugins/custom-login-and-registration-forms-plugin/

    which allows you to customize your login page.

    Both plugins are old and don't seem to be maintained, which is too bad -- maybe someone like you will take them on....

  3. raygene
    Member
    Posted 6 years ago #

    It is unfortunate that quite a few plugin authors don't update their plugins, I was expecting the IWG Hide Dashboard plugin (works in conjuction with the Role Manager plugin by the same author0 to be upgraded but there's no mention of it on his blog. I left him messages on both his blog and on this forum but to no avail.

    Plugin link:
    Hide Dashboard plugin

    Cheers,
    Gene

  4. blueharmony
    Member
    Posted 5 years ago #

    Hi Gene -- great set of fixes. I just implemented them and they work as you say. Now, if only there were a way to remove the 'Dashboard' link from a subscriber's back-end view.

  5. scottyg217
    Member
    Posted 5 years ago #

    There is a way. I finally found the plugin. Since I found it on this page I will post it here.
    http://www.kpdesign.net/wp-plugins/wp-hide-dashboard/

    Works with 2.7

Topic Closed

This topic has been closed to new replies.

About this Topic