Skip to content

Commit

Permalink
Address potential issue with frontend profile editing
Browse files Browse the repository at this point in the history
Check whether global `$pagenow` has a value before relying on it. Since the hook is called using `admin_init`, I'm not sure exactly how the user has reached this code, but it's possible it could be called manually or via AJAX.

It's not a problem to check for it and to use the alternative code suggested by @shivchawla

Co-Authored-By: shivchawla <shivchawla2001@gmail.com>
  • Loading branch information
zackkatz and shivchawla committed Apr 19, 2022
1 parent 8b5b545 commit cd11239
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inc/class.rda-remove-access.php
Expand Up @@ -113,7 +113,7 @@ function dashboard_redirect() {
/** @global string $pagenow */
global $pagenow;

if ( 'profile.php' != $pagenow || ! $this->settings['enable_profile'] ) {
if ( ( $pagenow && 'profile.php' !== $pagenow ) || ( defined( 'IS_PROFILE_PAGE' ) && ! IS_PROFILE_PAGE ) || ! $this->settings['enable_profile'] ) {
wp_redirect( $this->settings['redirect_url'] );
exit;
}
Expand Down
3 changes: 3 additions & 0 deletions readme.txt
Expand Up @@ -99,6 +99,9 @@ example.com/options-general.php?page=dashboard-access&rda_debug=1

== Changelog ==

= 1.1.4 on April 18, 2022 =

* Resolved: Issue when front-end editing of profiles when the `$pagenow` global is not defined ([#24](https://github.com/trustedlogin/Remove-Dashboard-Access/issues/24))
= 1.1.3 =

* Fixed a compatibility issue with bbPress and the media grid view.
Expand Down

0 comments on commit cd11239

Please sign in to comment.