Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blueprints: set_current_user to admin before activating plugins and themes #984

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

adamziel
Copy link
Collaborator

Sets the current user to admin before activating plugins and themes.

Rationale

Issue #911 uncovered a problem where activating a plugin does not create a page in the following scenario:

function myplugin_activate() {
    if( current_user_can( 'activate_plugins' ) ) {
        create_page();
    }
}
register_activation_hook( __FILE__, 'myplugin_activate' );

The root cause is that the activatePlugin and activateTheme steps do not set the current user to admin before activating the plugin/theme.

Testing instructions

This PR comes with unit tests – confirm the CI checks pass.

Closes #911

…hemes

Sets the current user to admin before activating plugins and themes.

 ## Rationale

Issue #911 uncovered a problem where activating a plugin does not create
a page in the following scenario:

```php
function myplugin_activate() {
    if( current_user_can( 'activate_plugins' ) ) {
        create_page();
    }
}
register_activation_hook( __FILE__, 'myplugin_activate' );
```

The root cause is that the activatePlugin and activateTheme steps do
not set the current user to admin before activating the plugin/theme.

 ## Testing instructions

This PR comes with unit tests – confirm the CI checks pass.
@adamziel adamziel added [Type] Bug An existing feature does not function as intended [Package][@wp-playground] Blueprints labels Jan 30, 2024
@adamziel adamziel merged commit cb7fa51 into trunk Jan 30, 2024
5 checks passed
@adamziel adamziel deleted the activate-plugins-themes-as-admin branch January 30, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package][@wp-playground] Blueprints [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Page not created on plugin activation
1 participant