Prevent Profile page as default backend page, but enable “Edit my Profile”

Question

I use Adminimize plugin to disabled most of the sections in backend for a certain user role, only my plugin-made pages remained available for that user role.

The behavior is that after a user with that user role logins, it goes to the Profile page.

I use the following codes in my plugin’s main script to prevent Profile page to be loaded at the first page after login:

// Skip and Hide Profile
add_action('load-profile.php', function() {
    if(check_if_certain_user_role()) {
        exit(wp_safe_redirect( menu_page_url('myplugin-first-page', false)));
    }
});

The above script works, and it forwards to my plugin’s first menu page myplugin-first-page. However, in the right top menu’s “Edit My Profile” link, it cannot be accessed, it will also forward to my plugin’s first page.

How can I adjust this behavior to allow user to go to Profile page only via the “Edit My Profile” link?

Thanks in advance.

0
, Raptor 11 months 0 Answers 52 views 0

Leave an answer