Send notification of uploaded file with scheduled publication date

    • massimo tito
      Membre
      # il y a 3 années et 5 mois

      Hi,
      I have the “Notification” plugin to send an email to the client when a file is uploaded to the reserved area, this works correctly if I upload a file and click on the publish button.

      However, I would like to send a notification with the scheduled publication date of the uploaded file, but this function does not work.
      The status of the file changes without sending the mail. (See Attachment)

      Can you help me make it work?

      Thank

    • Thomas
      Maître des clés
      # il y a 3 années et 5 mois

      Hi,

      You are right, the notification is actually sent when you click on the publish button AND if the checkbox is checked.

      This feature is not planned on our side, I won’t lie, but you can probably do that by yourself with a few lines of code.

      1. First, you’ll need to hook into the scheduled published posts
      2. Then, you’ll need to use the $object variable to get the ID of the post and use our Notifications PHP class to send the appropriate notifications.

      So, I think that this kind of code might be a starting point for you (not tested, probably needs testing and debugging)

      function wpca_scheduled_post_published($object)
      {
          $post_id = $object->post->ID;
          if(!cuar_is_customer_area_private_content($post_id)) return;
          
          $notifications = cuar_addon('notifications');
          $notifications->hooks_helper->on_private_post_published($post_id);
      }
      add_action('future_to_publish', 'wpca_scheduled_post_published');

      If you want to see what the on_private_post_published function is doing, you’ll find it in wp-content/plugins/customer-area-notifications/src/php/helpers/notifications-hooks-helper.class.php, line 708.

      Best regards.

      Want to help WP Customer Area? It only takes few seconds!
      Rate & review the plugin on WordPress.org 🙂

    • Thomas
      Maître des clés
      # il y a 3 années et 5 mois

      Edit: I don’t think it will work because the hooks_helpers class is marked as private instead of public in our PHP classes, in file wp-plugins/customer-area-notifications/src/php/notifications-addon.class.php, line 19. It means you can’t access it and uses this kind of code.

      Maybe try to change it to public and see if it works. Else, we’ll attempt to add that into the next release.

      Regards.

      Want to help WP Customer Area? It only takes few seconds!
      Rate & review the plugin on WordPress.org 🙂

    • massimo tito
      Membre
      # il y a 3 années et 5 mois

      Hi,
      thanks for the answer, your code worked, I had to change the variable $post_id = $post->ID;

      I modified the file customer-area-notifications/src/php/helpers/notifications-admin-interface.class.php to set the notifications checkbox to always be checked when creating a new file.

      I have another question, can I add an email address when sending the email?

      for example: customer email + Bcc: Admin Email

      thank you

    • Thomas
      Maître des clés
      # il y a 3 années et 5 mois

      That code worked? Hmmm.. Ok. Strange ^^

      Don’t forget to add

      global $post;

      before

      $post_id = $post->ID;

      Also, if you edit some plugins file, you’ll lose your modifications on the next plugins update.
      If you look at the code, you’ll see there is a filter returning an empty string value, named cuar/notifications/send-notification-meta-box/default-checkbox-value

      So, simply create a function (in a custom WP plugin, see code snippets documentation) bound to that filter, and return ‘checked’ instead of ” and it should work.

      To customize the notification recipients programmatically, I took a look at the code, and the only way I see, for now, is to take a look at the function send_mass_notification in customer-area-notifications/src/php/helpers/notifications-mailer-helper.class.php line 33.

      There is an action hook you can use to bind another function there and add your own tasks code there. You can use the passed $recipient_ids and use that to send additional emails.

      // Done
      do_action('cuar/notifications/on-mass-notification-sent', $recipient_ids, $notification_id, $post_id, $extra);

      Regards.

      Want to help WP Customer Area? It only takes few seconds!
      Rate & review the plugin on WordPress.org 🙂

    • massimo tito
      Membre
      # il y a 3 années et 5 mois

      Hi,
      I followed your directions and everything works fine.
      I added all the functions that I created in the function.php file, in particular I put an add_action( ‘cuar/notifications/on-email-sent’, ‘add_email_notification’, 10, 5 ); to add an email address (Bcc) to have greater control over all emails sent.

      This works correctly.

      Thank you

    • Thomas
      Maître des clés
      # il y a 3 années et 5 mois

      Hi,

      Thank you for the feedback.

      I’m happy those solutions worked. If in any case, you want to give the plugin a bit of support, do not hesitate to write a review on the WP repository, that would be greatly appreciated!

      Best regards.

      Want to help WP Customer Area? It only takes few seconds!
      Rate & review the plugin on WordPress.org 🙂

Vous lisez 6 fils de discussion

The topic ‘Send notification of uploaded file with scheduled publication date’ is closed to new replies.