BuddyDev

Search

BuddyBlog Pro – override Submit Post for Review

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #49101

    Hello Nick,

    Please try the following code:

    
    
    /**
     * Skip notification on post submit
     *
     * @param null    $skip_notify  Need to notify or not.
     * @param WP_Post $post         Post object.
     * @param int     $form_id      Form id.
     *
     * @return mixed
     */
    function buddydev_skip_post_submit_notification( $skip_notify, $post, $form_id ) {
    
    	if ( 'publish' === bblpro_get_default_post_status_for_user( get_current_user_id(), $form_id, $post->ID ) ) {
    		$skip_notify = true;
    	}
    
    	return $skip_notify;
    }
    add_filter( 'bblpro_pre_handle_post_submission_admin_notification', 'buddydev_skip_post_submit_notification', 10, 3 );
    add_filter( 'bblpro_pre_handle_post_submission_author_notification', 'buddydev_skip_post_submit_notification', 10, 3 );
    
    

    Please do let me know if it works or not.

    Regard
    Ravi

  • Participant
    Level: Master
    Posts: 279
    NikB on #49102

    Hi Ravi

    Thank you so much.

    That seems to work well for personal posts, but it’s not catching group posts ie. emails are still getting sent out even for posts that are published immediately. I’m guessing that needs another filter but it’s not immediately obvious what it should be. Any suggestions?

    With many thanks again
    Nik

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #49103

    Hello Nik,

    Thank you for the acknowledgement. I will check for group’s post and will get back to you soon.

    Regards
    Ravi

  • Participant
    Level: Master
    Posts: 279
    NikB on #49121

    Hi Ravi

    Thank you very much. The group admins are finding it quite confusing to receive emails telling them their own posts need approval (even though I’ve told them just to ignore ;-)).

    With many thanks in advance and I’ll look forward to hearing from you.
    Nik

  • Participant
    Level: Master
    Posts: 279
    NikB on #49147

    Hi Ravi

    Sorry to follow up on this so soon but just wondering if you’ve had a chance to look at the groups emails yet?

    I’ve had a look at the code and unfortunately there doesn’t seem to be a filter for the group notifications so not sure how best to handle?

    With many thanks in advance and will look forward to hearing from you.
    Nik

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #49148

    Hello Nik,

    Sorry for the delayed reply. I have tried this on my development server and it is working fine for me i.e. No post-approval mail is sent. Can please try again on a fresh WordPress setup?

    Regards
    Ravi

  • Participant
    Level: Master
    Posts: 279
    NikB on #49149

    Hi Ravi

    Thank you for getting back to me but I think there may be some confusion. It’s not the post approval email that is the problem…

    The problem is that when group admins or editors (whose default post status is set to “publish”) make a post, it gets published immediately and therefore they do not expect to receive the admin and author notification emails.

    The above code you suggested works well for editors when publishing personal posts, but does not stop emails getting sent out when editors or group admins make a group post (with BuddyBlog Groups Pro), which as far as I can tell, handles notifications slightly differently.

    Hopefully that clarifies things a bit?

    Regards
    Nik

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #49150

    Hi Nik,
    Thank you.
    That makes sense!

    Would you be able to link me to screenshots from your form work flow and your group posts settings(on group manage page). That would give us a lot more insight and help us resolve it.

    Thank you
    Brajesh

  • Participant
    Level: Master
    Posts: 279
    NikB on #49164

    Hi Brajesh/Ravi

    I’m not sure how to upload screenshots here but hopefully the following will help –

    Group Posts Form workflow –

    On submission: Submit post for review
    Admin notification: Yes
    Group Admin notification: Yes
    Post author notification: Yes
    On approval – post author notification: Yes

    Groups settings (set in WP/site admin dashboard) –
    Posts tab: Availability – All groups/Visibility – Everyone
    Sub posts tab: Availability – All groups/Visibility – Everyone
    Create posts tab: Availability – All groups/Visibility – Group members
    Pending & edit tabs: Availbility – All groups/Visbility – Group moderators

    No overrides are allowed by group admins ie. all posts in all groups throughout the site are to be handled in the same way (so there is no group posts settings page on the group manage page).

    As you would expect (and as the plugin is designed), the above works perfectly for regular group members (ie. those with the role of subscriber) ie. user submits a post for approval and emails are sent to the user, admin and group admin notifying them accordingly. When admin or group admin approves the post, email is sent to the user notifying them accordingly.

    However… group admins also want to add their OWN posts and in this case it makes no sense that those posts should require approval (since they themselves are the ones that are responsible for approving them).

    With your kind assistance (here – https://buddydev.com/support/forums/topic/buddyblog-pro-override-submit-post-for-review/page/3/#post-48737), I have used the bblpro_default_post_status_for_user filter to allow posts made by group admins to be published immediately ie. status is automatically set to “published” not “pending”. This also works perfectly however…

    The one outstanding issue is that despite the fact that posts by group admins are published immediately, they (and site admin) are still receiving the (on submission) notification emails advising them that “a post has been received and needs approval”, and in the case of group admins, also the (on submission) post author notification email.

    In summary… if the bblpro_default_post_status_for_user is set to “published” (as it is for group admins) then I want to be able to stop all “on submission” emails/notifications from being sent out.

    Note: the code suggested by Ravi above (https://buddydev.com/support/forums/topic/buddyblog-pro-override-submit-post-for-review/page/4/#post-49101) works perfectly when handling a similar situation for profile posts (ie. if a post is made by a user with bblpro_default_post_status_for_user set to “published” no notifications are sent out) however… for some reason this has no effect on group post notifications.

    I really hope this helps but if you need any further clarification, please do let me know.
    With many thanks again
    Nik

  • Participant
    Level: Master
    Posts: 279
    NikB on #49177

    PS. The above is all starting to look very complicated but all(?) I really want to do is to prevent any notification emails getting sent out when bblpro_get_default_post_status_for_user = “publish”.

    The code suggested above by Ravi works well for members posts, but does not stop notifications relating to group posts being sent out.

    With many thanks again and will look forward to hearing from you.
    Nik

You must be logged in to reply to this topic.

This topic is: not resolved