Skip to content

Respect users locale and custom date- and time-formats in sent emails#922

Merged
mauteri merged 4 commits intoGatherPress:mainfrom
carstingaxion:fix/fragment-of-752-send-emails-in-users-locale
Sep 26, 2024
Merged

Respect users locale and custom date- and time-formats in sent emails#922
mauteri merged 4 commits intoGatherPress:mainfrom
carstingaxion:fix/fragment-of-752-send-emails-in-users-locale

Conversation

@carstingaxion
Copy link
Copy Markdown
Collaborator

@carstingaxion carstingaxion commented Sep 26, 2024

Fragmentation of #752

Until this PR, sent emails dont respect the users locale nor her personal date- and time formatting settings.

Description of the Change

This PR fixes that, by:

  • Loading the users locale before sending emails & resetting it afterwards
  • Set the current user to the actual member to mail to, to make sure the GatherPress filters for date- and time- format, as well as the users timezone, are recognized by the functions inside render_template()

Closes #

How to test the Change

Testing this PR might be a little tricky and is not possible with WordPress Playground because of the necessary sending & receiving of emails.

Preparation to test:

  1. Setup at least two different users
  2. One of the users creates an event, the other users attends. (This will make sure, 2 emails are sent for the test)
  3. Assign a non-site-default language to one of the users in their profile.php
  4. Go to Updates, get to the bottom of the page and hit the "Update translations" button.
  5. Make sure that in the following screen, the translation files for the selected non-site-default language gets downloaded!

Testing this PR:

  1. Edit the newly created event
  2. Compose a message via Email
  3. Send email
  4. Check the results, one email should follow the user-defined language, while the other is sent in the default locale

Changelog Entry

Fixed - Respect users locale and custom date- and time-formats in sent emails

Credits

Props @carstingaxion

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

…e GatherPress filters for date- and time- format, as well as the users timezone, are recognized by the functions inside render_template().
@github-actions
Copy link
Copy Markdown
Contributor

Preview changes with Playground

You can preview the recent changes for PR#922 with the following PHP versions:

PHP Version 8.3

PHP Version 7.4

Download .zip with build changes

Made with 💙 from GatherPress & a little bit of WordPress Playground. Changes will not persist between sessions.

@carstingaxion carstingaxion linked an issue Sep 26, 2024 that may be closed by this pull request
1 task
@mauteri mauteri merged commit 0bab53e into GatherPress:main Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set user-timezone & user-locale in emails

2 participants