Make it clear that a newsletter can only be sent once

Created on 5 February 2025, 2 months ago

Problem/Motivation

In Allow resending of newsletters Fixed , resending a newsletter to select emails was made possible, but you can still only send a newsletter once to a mailing list. This can be confusing for new users, and not obvious that this is so.

Anyway, there are good reasons to not allow this, since:

... there is a very real danger of sending the same newsletter to the same people, which would tend to be called spam.

Steps to reproduce

Begin using the Simplenews module, send a test newsletter, and wonder why the "Send now" button has gone away, since you want to send it again.

Proposed resolution

Make it very obvious that you can only send a newsletter once, by adding the sentence "You can only send a newsletter once":

  1. Next to the "Send now" button
  2. After the "Newsletter issue sent to ..." text

This is a rough draft, and making new users aware of this directly in the user interface can be solved in other ways, but this can get the discussion started.

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

4.0

Component

Code

Created by

🇩🇰Denmark ressa Copenhagen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @ressa
  • Merge request !83Add tip about sending is only possible once → (Merged) created by ressa
  • 🇩🇰Denmark ressa Copenhagen
  • 🇩🇰Denmark ressa Copenhagen
  • Pipeline finished with Failed
    2 months ago
    Total: 599s
    #416075
  • 🇩🇰Denmark ressa Copenhagen

    Add suggestion to perhaps show an inactivate greyed-out button, which says "Sent".

  • Pipeline finished with Failed
    about 2 months ago
    Total: 816s
    #430235
  • Pipeline finished with Success
    about 2 months ago
    Total: 471s
    #430870
  • 🇬🇧United Kingdom adamps

    It's a balance - we don't want to clutter the UI for experienced users with stuff they already know. I feel that help text should be separate from essential UI text.

    Here's a suggestion. Instead of the changes in the current MR, we make just one change to NodeTabForm in the case that the newsletter has been sent (this is the point at which the "send now" button is 'missing').

    There is already some indication of what's going on:

    Newsletter issue sent to 4 subscribers, 0 errors.

    We can make it more obvious. We could make the '#type' => 'details', wrapper be present always (move it outside the if test). Then in the case where there is no button, we can if you like make the button appear but disabled, and add a sentence "Newsletters can only be sent once.".

  • Pipeline finished with Canceled
    about 1 month ago
    Total: 396s
    #445785
  • Pipeline finished with Success
    about 1 month ago
    Total: 661s
    #445792
  • 🇩🇰Denmark ressa Copenhagen

    Thanks for taking a look at this @adamps, and that's a great and simpler suggestion, since only a single file needs to be updated. I had to unset the fieldset, since a convoluted elseif solution could become too complex, I think ...

  • 🇩🇰Denmark ressa Copenhagen

    A customer of mine just ran into a big problem: They cloned a newsletter with Quick Node Clone and spent quite some time editing it.

    But when they wanted to send it, the "Send now" button was missing, since values, including the "Sent"-status had been cloned.

    I think overall, that it would be nice to clearly signal to a user editing an already sent newsletter, that it has indeed already been sent, to prevent them from spending much time in vain. So I am expanding the scope, to include a warning on the Edit page.

    Also, editing an already sent newsletter will mostly not make any sense, so adding this message would be nice.

  • 🇬🇧United Kingdom adamps

    Thanks.

    Good idea for the edit page. There is already code in simplenews_form_node_form_alter() for SIMPLENEWS_STATUS_SEND_PENDING. I suggest we expand that to include other status types.

    Thanks for the screenshot. I would like to move "Newsletter issue sent to 1 subscribers, 0 errors." to be above the disabled "sent" button? This would match the message prior to sending "Send newsletter issue to 1 subscribers. " Currently I find it hard to notice at the bottom. We could use the same code $form['send']['count'] = , just the actual message differs based on the status. We could even put "Newsletters can only be sent once." into $form['send']['method']. I like the idea that the form becomes much more consistent across the different states.

    However there is a question of back-compatibility in case anyone customised the form. Perhaps if we make a new minor release and document it?

  • Pipeline finished with Canceled
    29 days ago
    Total: 631s
    #449731
  • 🇩🇰Denmark ressa Copenhagen

    Great feedback and tips. I moved the warning above the button like you suggested, and that does work better.

    I also added the message on the edit form, where you suggested, that'll be helpful, and prevent pointless editing. At first, it was inside the if (!$node->isNew()) { section, but then it wouldn't be shown if you use Quick Clone, like I did ... Placing it on its own like now, it will be shown both when editing or cloning a sent newsletter.

    This idea sounds a bit like my initial MR?:

    We could even put "Newsletters can only be sent once." into $form['send']['method']. I like the idea that the form becomes much more consistent across the different states.

    Creating a new minor release and documenting it sounds like a plan :)

  • Pipeline finished with Success
    29 days ago
    Total: 642s
    #449734
  • 🇬🇧United Kingdom adamps

    Great I like it. Yes your initial MR had some good ideas.

    Please can we take one more step to simplify the code (and it also solves a bug)? I made some detailed comments in the MR.

  • 🇩🇰Denmark ressa Copenhagen

    Thanks for the review. It's not clear to me though, what exactly needs to happen ... Do you know about the Insert suggestion button?

    I think it would be easier if you used that one for each suggested change. Then I can simply click "Apply suggestion" and your suggested code change gets implemented. I think that's easier for this refactoring, since I am not sure what needs to be done ...

  • 🇬🇧United Kingdom adamps

    Good idea. I didn't see the suggest changes button, so I've just posted my code here. Please let me know what you think.

        // Show newsletter sending options.
        $form['send'] = [
          '#type' => 'details',
          '#open' => TRUE,
          '#title' => $this->t('Send'),
        ];
    
        // Add some text to describe the send situation.
        $form['send']['count'] = [
          '#type' => 'item',
          '#markup' => $summary['description'],
        ];
    
        if (($status == SIMPLENEWS_STATUS_SEND_NOT) || ($status == SIMPLENEWS_STATUS_SEND_READY)) {
          if ($status == SIMPLENEWS_STATUS_SEND_READY) {
            $send_text = $this->t('Newsletters can only be sent once.');
          }
          elseif (!$node->isPublished()) {
            $send_text = $this->t('Mails will be sent when the issue is published.');
            $button_text = $this->t('Send on publish');
          }
          elseif (!$config->get('mail.use_cron')) {
            $send_text = $this->t('Mails will be sent immediately.');
          }
          else {
            $send_text = $this->t('Mails will be sent when cron runs.');
          }
    
          $form['send']['method'] = [
            '#type' => 'item',
            '#markup' => $send_text,
          ];
    
          $form['send']['send'] = [
            '#type' => 'submit',
            '#button_type' => 'primary',
            '#disabled' => $status == SIMPLENEWS_STATUS_SEND_READY,
            '#value' => $button_text ?? $this->t('Send now'),
          ];
        }
        else {
          $form['send']['stop'] = [
            '#type' => 'submit',
            '#submit' => ['::submitStop'],
            '#value' => $this->t('Stop sending'),
          ];
        }
    
        return $form;
    
    
  • 🇩🇰Denmark ressa Copenhagen

    Thanks! Though, it's not a button, sorry.

    Here is a link on how to create suggestions in GitLab. I believe everyone would benefit from knowing about it, since it can make the development process easier. And Drupal will be using GitLab going forward after all:

    https://docs.gitlab.com/user/project/merge_requests/reviews/suggestions/...

    If you can't be bothered that's all right, then I'll do it the other way. Just let me know.

  • 🇬🇧United Kingdom adamps

    Thanks for explaining I agree that is useful for me to know. I had a look and I feel that the suggestions work better for smaller changes.

  • 🇩🇰Denmark ressa Copenhagen

    Yes, you're probably right. I updated the MR, and the new code works well: I get the "Newsletters can only be sent once." message after sending a newsletter, and a greyed out button, so it looks good to me.

  • Pipeline finished with Failed
    9 days ago
    Total: 491s
    #466373
  • Issue was unassigned.
  • Status changed to Needs work 6 days ago
  • 🇬🇧United Kingdom adamps

    Great thanks, the code looks good.

    It now needs a few simple test fixes for the changed wording. Plus it would be great to have one new test to check the new message appears. There should likely be an existing test where we could just add a single line.

  • Pipeline finished with Failed
    6 days ago
    Total: 1777s
    #468306
  • Pipeline finished with Success
    6 days ago
    Total: 1608s
    #468321
  • 🇩🇰Denmark ressa Copenhagen

    Sounds great, and I have updated the failing tests, and found a place where I could add a test for the new message.

  • Pipeline finished with Skipped
    3 days ago
    #470871
  • Pipeline finished with Skipped
    3 days ago
    #470873
  • Pipeline finished with Skipped
    3 days ago
    #470877
  • Pipeline finished with Skipped
    3 days ago
    #470878
  • Pipeline finished with Skipped
    3 days ago
    #470896
  • Pipeline finished with Skipped
    3 days ago
    #470897
  • Pipeline finished with Skipped
    3 days ago
    #470898
  • Pipeline finished with Skipped
    3 days ago
    #471009
  • Pipeline finished with Skipped
    3 days ago
    #471011
  • 🇬🇧United Kingdom adamps

    Great thanks, I like the improved form and helpful text.

  • 🇩🇰Denmark ressa Copenhagen

    Nice, thanks for maintaining Simplenews, which I really appreciate -- it works really well.

    PS: I just noticed a detail: This sentence is missing a dot at the end: "This newsletter issue has already been sent"
    simplenews.module, line 300.

Production build 0.71.5 2024