WordPress.org

Ready to get started?Download WordPress

Forums

Edit Flow
[resolved] Code to partially turn off auto-subscribe (8 posts)

  1. mcstevem
    Member
    Posted 2 years ago #

    Can you share the full code snippet that would turn off auto-subscribe? Even better, that would turn off auto-subscribe for users editing a post, but leave it enabled for users adding an editorial comment? (That would get me past the Catch-22 where I can't unsubscribe myself because doing so is editing a post, which re-subscribes me ...) I've seen the ef_notification_auto_subscribe_current_user filter listed on the Notifications page of the EditFlow site, but not being a developer I don't know the full syntax that would need to be added to functions.php to achieve my aims.

    Thanks, and I'm loving the updated plugin for our university news site.

    http://wordpress.org/extend/plugins/edit-flow/

  2. Scott Bressler
    Member
    Plugin Author

    Posted 2 years ago #

    If you don't want to auto-subscribe yourself either when adding a comment or when editing the post, simply add the following to functions.php:

    add_filter( 'ef_notification_auto_subscribe_current_user', '__return false' );

    If, instead, you only want to turn off auto-subscription for one of those two actions, you'd do something like the following:

    function efx_dont_auto_subscribe_for_editorial_comments( $auto_subscribe, $subscription_type ) {
      if ( $subscription_type === 'comment' )
        return false;
      return $auto_subscribe;
    }
    add_filter( 'ef_notification_auto_subscribe_current_user', 'efx_dont_auto_subscribe_for_editorial_comments', 10, 2 );

    To instead turn off auto-subscription only when editing a post (rather than posting an editorial comment), change the first line of the function to:
    if ( $subscription_type === 'subscription_action' )

    Hope that helps!

    -Scott

  3. Scott Bressler
    Member
    Plugin Author

    Posted 2 years ago #

    I've added a page explaining a solution to this question in even more detail on our web site here: http://editflow.org/extend/disable-auto-subscribing-users-for-notifications/

  4. Scott Bressler
    Member
    Plugin Author

    Posted 2 years ago #

    Steve, did this code work for you?

  5. mcstevem
    Member
    Posted 2 years ago #

    Scott, I've been in meeting hell since I posted the request. I'm hoping to try out the code this afternoon, so that I can include it in training sessions I'll be presenting next week.

  6. mcstevem
    Member
    Posted 2 years ago #

    I added the code to functions.php, reversing the situation so that it would disable auto-subscribes for post changes but keep them for comments, and it worked exactly as desired. Thanks!

    The piece that isn't quite as expected is that the original post author is no longer auto-subscribed when the post it first created (part of the problem reported by hermy65 in a separate thread). Now that there's a way to allow users to unsubscribe themselves, I'd lobby to restore the auto-subscription of author upon creation, as the author is the person most likely to want to know about changes or comments.

  7. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 2 years ago #

    Intriguing... I'm out of town but will take a more detailed look early this coming week.

  8. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 2 years ago #

    As it turns out, this is a bug and regression :) I'm working on a solution now and it will be out in v0.7.1. Sorry for the inconvenience.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic