• Resolved jonsp

    (@jonsp)


    I’d like to have a site set up so people can register as subscribers, after which point I’d want them only to be able to access their profile on the backend and then the full front end site.

    I’m having trouble at the moment figuring out how to keep them from being able to access /wp-admin/index.php (the dashboard) after they’ve logged in. They are taken automatically to their profile since they are subscribers, but they can access index.php, so this isn’t urgent but I’d like it to be clean.

    I tried the following with no results

    function logged_in_home_redirect() {
        if( ($current_url = home_url( '/wp-admin/index.php' )) && !($current_url = home_url( '/wp-admin/profile.php' ))) {
            wp_redirect( home_url( '/wp-admin/profile.php' ) );
            exit;
        }
    }
    
    if (!current_user_can('administrator')) :
    add_action( 'init' , 'logged_in_home_redirect' );
    endif;

    I’m looking for something quick and effective to plop into my functions.php file. Thanks in advance for any assistance that can be offered.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I realize you’re working toward a solution that you can put right in a functions file, but take a peek at this plugin and see if it might be of any help. I’ve used this in the past to limit the subscriber role to viewing only their profile and the site itself. I seem to recall it being pretty effective.

    I know it appears a bit dated, but if it doesn’t flat out work the way you need it to, it might provide some insight on how to get there.

    WP Hide Dashboard

    Thread Starter jonsp

    (@jonsp)

    There’s a little bit of code in that plugin that does exactly what I want. I’ll work on pulling out just the code that I need. Thank you for pointing me in that direction!

    You’re welcome!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘redirect /wp-admin/index.php to /wp-admin/profile.php’ is closed to new replies.