Allows users to opt into receiving a notification email whenever a comment is made to the site.
This plugin adds a checkbox to the profile page for users which allows them to opt into receiving a notification email whenever a comment is made to the site.
If a comment goes into moderation, only users who have the ability to manage comments on the site will receive the moderation notification email.
By default, all users of the site have the ability to subscribe to notifications about comments. A filter is provided to facilitate use of code to customize the feature’s availability to users.
Note: a “user” is a person with an actual login account for the site. The plugin does not facilitate permitting visitors who do not have an account on the site to be able to subscribe to all comments.
Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
optin-comment-notifications.zip
inside the plugins directory for your site (typically wp-content/plugins/
)Any user account on the site can sign up for comment notifications. Comments that go into moderation will only trigger notifications to users who can moderate comments. Visitors who do not have an account on the site cannot make use of the plugin to subscribe to comments.
On your profile page, there is a checkbox next to “New Comment Emails” that is labeled “Email me whenever a comment is submitted to the site.”. Check the checkbox and click the button to update your profile. If you wish to discontinue receiving such notifications, simply uncheck the checkbox and save the change.
Yes.
Use the ‘c2c_optin_comment_notifications_has_cap’ filter to customize the capability as needed. The following code can be used or adapted for that purpose. Such code should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain).
/** * Only permits administrators and editors to subscribe to comment notifications. * * @param bool $default The default. Default true. * @param array $caps Array of user capabilities. * @return string */ function restrict_optin_comment_notifications( $default, $caps ) { // Only administrators and editors can subscribe to all comments. return !! array_intersect( wp_get_current_user()->roles, // Get current user's roles. array( 'administrator', 'editor' ) // Roles to allow to subscribe to all comments. ); } add_filter( 'c2c_optin_comment_notifications_has_cap', 'restrict_optin_comment_notifications', 10, 2 );
Yes. Users with the ‘edit_users’ capability (administrators, basically) and can edit the profile of another user can configure this plugin for that user. The checkbox is labeled “Email this user whenever a comment is submitted to the site.”.
do_init()
into init()
wp_new_comment_notify_postauthor()
rather than plugin class methodWP_TESTS_DIR
to /tmp/wordpress-tests-lib
rather than erroring out if not defined via environment variable.Full changelog is available in CHANGELOG.md.