trustedlogin / Remove-Dashboard-Access

This WordPress plugin limits user access to the dashboard based on whether users have a chosen capability. Disallowed users are redirected to a chosen URL.
https://wordpress.org/plugins/remove-dashboard-access-for-non-admins/
49 stars 12 forks source link

Check for profile page looks incorrect/incomplete #24

Closed shivchawla closed 2 years ago

shivchawla commented 4 years ago

I am using a plugin that let's me modify the user profile from front-end. But with this plugin, the plugins doesn't work even when "Enable Profile" is true. I guess the check for profile page in the code below looks incorrect. I have suggested the change. Let me know what you think.

Current way :

function dashboard_redirect() {
        /** @global string $pagenow */
        global $pagenow;

        if ( 'profile.php' != $pagenow || ! $this->settings['enable_profile'] ) {
            wp_redirect( $this->settings['redirect_url'] );
            exit;
        }
    }

Suggested Way:

function dashboard_redirect() {
        if ( ! IS_PROFILE_PAGE || ! $this->settings['enable_profile'] ) {
            wp_redirect( $this->settings['redirect_url'] );
            exit;
        }
    }