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

Filter for disabling the notice box? #190

Closed
khromov opened this issue Apr 17, 2014 · 2 comments · Fixed by #507
Closed

Filter for disabling the notice box? #190

khromov opened this issue Apr 17, 2014 · 2 comments · Fixed by #507

Comments

@khromov
Copy link

khromov commented Apr 17, 2014

Is it possible to add a filter for disabling the notice box? We're working on a multisite installation with a parent theme that uses TGM and we don't want it to show up on every admins profiles.

We have hooked into get_user_metadata to override the default setting value globally, but it would be better if there was a native filter available.

Here's the code we are using now:

add_filter('get_user_metadata', function($val, $object_id, $meta_key, $single)
{
    if($meta_key === 'tgmpa_dismissed_notice')
        return true;
    else
        return null;

}, 10, 4);

More info:
http://snippets.khromov.se/disable-tgm-plugin-activation-nag-screen/

@jrfnl
Copy link
Contributor

jrfnl commented Jan 13, 2015

@khromov PR #247 makes it so that on multisite, the notices are only shown in the network admin. Hope this helps a bit. Feel free to +1 it if you approve of the PR.

Oh and to completely disable the admin notices, just change 'has_notices' in your config array to false, no filter needed (has been available since v2.1.0):
$config['has_notices'] = false;

jrfnl added a commit that referenced this issue Jan 5, 2016
By default the following logic will be used:
User < 'publish_posts': no admin notices
User < install/update/activate: "contact administrator notice" without disclosing information about the plugins involved and only if there are *required* plugins which require action.
User = install/update/activate: "normal" notices

The minimum user level for which admin notices are shown at all can be adjusted by using the newly introduced `tgmpa_show_admin_notice_capability` filter. The default is set to 'publish_posts', i.e. Authors.

Example:
add_filter( 'tgmpa_show_admin_notice_capability', create_function( '$cap', 'return \'edit_pages\';' ) );

To only show the admin notices to network admins on multisite, set it to a super admin capability like 'manage_network_plugins'.

Note: the `notices()` function is ugly and in desperate need of refactoring, that is not handled in this PR (which only makes it worse).

Fixes #190, #414
Supersedes: https://github.com/INN/Largo/pull/740/files
Partially fixes #479, #489 - notice will now only show for required updates for non-admin users with level author or editor.
Possibly fixes #492, though more information is needed on the actual case.
jrfnl added a commit that referenced this issue Jan 5, 2016
By default the following logic will be used:
User < `'publish_posts'` (=Author): no admin notices
User < install/update/activate: "contact administrator notice" without disclosing information about the plugins involved and only if there are *required* plugins which require action.
User = install/update/activate: "normal" notices

The minimum user level for which admin notices are shown at all can be adjusted by using the newly introduced `tgmpa_show_admin_notice_capability` filter. The default capability is set to `'publish_posts'`.

Example:
add_filter( 'tgmpa_show_admin_notice_capability', create_function( '$cap', 'return \'edit_pages\';' ) );

Another example:
To only show the admin notices to network admins on multisite, set it to a super admin capability like `'manage_network_plugins'`.

Note: the `notices()` function is ugly and in desperate need of refactoring, that is not handled in this PR (which only makes it worse).

Fixes #190, #414
Supersedes: https://github.com/INN/Largo/pull/740/files
Partially fixes #479, #489 - notice will now only show for required updates for non-admin users with level author or editor.
Possibly fixes #492, though more information is needed on the actual case.
jrfnl added a commit that referenced this issue Jan 5, 2016
By default the following logic will be used:
User < `'publish_posts'` (=Author): no admin notices
User < install/update/activate: "contact administrator notice" without disclosing information about the plugins involved and only if there are *required* plugins which require action.
User = install/update/activate: "normal" notices

The minimum user level for which admin notices are shown at all can be adjusted by using the newly introduced `tgmpa_show_admin_notice_capability` filter. The default capability is set to `'publish_posts'`.

Example:
add_filter( 'tgmpa_show_admin_notice_capability', create_function( '$cap', 'return \'edit_pages\';' ) );

Another example:
To only show the admin notices to network admins on multisite, set it to a super admin capability like `'manage_network_plugins'`.

Note: the `notices()` function is ugly and in desperate need of refactoring, that is not handled in this PR (which only makes it worse).

Fixes #190, #414
Supersedes: https://github.com/INN/Largo/pull/740/files
Partially fixes #479, #489 - notice will now only show for required updates for non-admin users with level author or editor.
Possibly fixes #492, though more information is needed on the actual case.
@khromov
Copy link
Author

khromov commented Jan 6, 2016

Nice! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants