Jump to content
plusplushosting

a hook to send an email to each client when there is a new announcements post

Recommended Posts

Hi guys!

Im looking for a hook that trigger a message sent to each Active clients when there is a new announcement post. I have two languages so if is possible have in both languages (depending if the client is set to default/language A o language B will be great. The message shouldnt be the announcement itself, just something like "hey, there is a new announcement, please check your client area at https.....". If it can use the templates great, if not a hardcoded text can work too.

Thanx in advance!

Share this post


Link to post
Share on other sites

I don't think you would be able to setup a hook to do what you want, as it will need several minutes to send all e-mails and will probably timeout.

Share this post


Link to post
Share on other sites

You could do use AnnouncementAdd (and edit), but one problem I see here is when the hook runs it will try to send all mail out at the same time.  That could cause issues, like some mail servers blocking you, and depending on how many there are the whole thing could timeout.  Instead, what I would recommend for this is a using AnnouncementAdd / AnnouncementEdit and a cron that calls an addon module that checks for the new announcement flag (or what have you) and then sends the emails in batches.  That would mimic the mass mail tool.  Or maybe figure out a way to use the mass mail tool for this purpose  

 

Share this post


Link to post
Share on other sites

well WHMCS have already declined the suggestion, so no point waiting for them to do this...

in addition to @steven99 suggestions, i'd add one more possibility - using MailChimp's RSS To Email feature...

https://mailchimp.com/help/share-your-blog-posts-with-mailchimp/

Quote

If you have a blog, you may want to use an RSS campaign to email new posts to your subscribed contacts. RSS campaigns use merge tags to pull in RSS (Real Simple Syndication) content from a blog feed. When an RSS feed is updated with new blog posts, Mailchimp will pull that content into the campaign and send it to your subscribers on the schedule you choose.

the WHMCS Announcements page creates it's own RSS feed, so that could be utilised by MailChimp for this purpose.

though if you're not creating announcements frequently, you may just find it easier to use the Mass Mail function directly in WHMCS.

Share this post


Link to post
Share on other sites

one more please....in the export section in whmcs i do not see an option to export clients data based in the language (im not sure how at this point where mailing is priority you cant filter by language in this area). Can you have at hand the mysql query to return the first name, last name and email address of all clients in the table by language? Im thinking to get a csv using phpmyadmin and then import it into mailchimp specific list for each language.

Also...as i said before...at this point not having a way that the mailchimp addon in whmcs be multi language is a bit frustrating. People signing up for example using French or spanish should receive the transactional email in the default language no make sense and probably is the worst thing you can do in marketing. Imagine being from US receiving an email in chinese 🙂

Thanx again!

Share this post


Link to post
Share on other sites
46 minutes ago, plusplushosting said:

one more please....

giphy.gif

46 minutes ago, plusplushosting said:

in the export section in whmcs i do not see an option to export clients data based in the language (im not sure how at this point where mailing is priority you cant filter by language in this area).

are you thinking of the Clients Report?

the problem here is that it's possible that WHMCS doesn't store the language for all clients in the database - if the client has chosen a language (e.g if they've changed it while logged in), then it will be stored in the tblclients table; if they haven't, then they will use the "default" language for your installation (as per your localisation settings) and the entry in the database will be empty.

46 minutes ago, plusplushosting said:

Can you have at hand the mysql query to return the first name, last name and email address of all clients in the table by language?

to get a list of English-specified language clients, you should just need to use...

SELECT tblclients.firstname,tblclients.lastname, tblclients.email FROM tblclients WHERE tblclients.`language` = 'english'

and then change the last term from 'english' to 'spanish' to get a Spanish list... if you're lucky, all your clients will be in one list or the other, but as I said previously, you may have some that will be in neither.

46 minutes ago, plusplushosting said:

Im thinking to get a csv using phpmyadmin and then import it into mailchimp specific list for each language.

if it helps, i've attached a modified version of the "Clients" report, just upload it to /modules/reports and you should be able to access it either via the front page of Reports or from the sidebar list...

yMUrwvU.png

with that, you can create filtered lists with specific languages (e.g english, spanish or leave blank)...

  • English -> J5J9kRQ.png
  • Spanish -> cYuE8gU.png
  • None (default) -> AdSNRQw.png

or don't select any filter options and you'll get an entire list of all your clients.

clients_with_language.php

Share this post


Link to post
Share on other sites
Just now, plusplushosting said:

great! Thanx very much Brian! If i type "default" ill get the "neither" clients ?

no leave the filter box blank (as in the third filter image) and it will find clients for you that are neither english or spanish.

 

Share this post


Link to post
Share on other sites
On 2/13/2019 at 9:52 AM, brian! said:

the WHMCS Announcements page creates it's own RSS feed, so that could be utilised by MailChimp for this purpose.

though if you're not creating announcements frequently, you may just find it easier to use the Mass Mail function directly in WHMCS. 

This was working great...until i have updated the spanish language file and changed the days of the week and months to the spanish one.....as far as i see rss is using the pubdate tag with the translated text and mailchimp rss is not recognizing it....any way to force the date in the pubdate in the rss be only in english format no matter if the announcement is post in different language? or any file to edit for the rss feed?

Thanx!

Share this post


Link to post
Share on other sites
18 hours ago, plusplushosting said:

This was working great...

uh oh!

18 hours ago, plusplushosting said:

any way to force the date in the pubdate in the rss be only in English format no matter if the announcement is post in different language?

I would have thought that you could pass a language to the RSS feed URL and it should use that language for the dates, e.g /annoucements/rss?language=english - i've just tried that locally with the language set to Spanish in WHMCS, but passing English in the RSS URL and it's outputting the pubDate in English rather than Spanish. 🙂

you could try changing the RSS URL in the MailChimp settings to include the language and see if that works with Mailchimp.

18 hours ago, plusplushosting said:

or any file to edit for the rss feed? 

they're all encrypted. ⚠️

Share this post


Link to post
Share on other sites

Hi Brian, i already have /annoucements/rss?language=spanish....but as i have translated the english.php language and the date (months, weekdays) are translated in spanish, the rss feed is getting those translated info, not recognizing the date.

keep in mind i have two lists...one for english, passing /annoucements/rss?language=englsih and one for spanish passing /annoucements/rss?language=spanish

Thanx!

Share this post


Link to post
Share on other sites
1 minute ago, plusplushosting said:

but as i have translated the english.php language and the date (months, weekdays) are translated in spanish, the rss feed is getting those translated info, not recognizing the date.

i'm confused - are you saying that you have an English overrides file that contains Spanish dates ?

Share this post


Link to post
Share on other sites

no, i have the spanish file with the dates translated into it: e.g

$_LANG['dateTime']['mon'] = "Mon";

to

 

$_LANG['dateTime']['mon'] = "Lun";

 

Then when you pas the rss url with the spanish tag in the url mailchimp is getting the translated date.

Share this post


Link to post
Share on other sites
Just now, plusplushosting said:

Then when you pas the rss url with the spanish tag in the url mailchimp is getting the translated date.

ok that makes sense - no obvious way around that (as WHMCS is working as expected) - only thing I can think to suggest would to remove/disable those overrides when you're updating an article or think the feed will be accessed by MailChimp.

Share this post


Link to post
Share on other sites

yup, is what i did, unfortunately as i have it set as automated email is a pain remove the translation every time.....the logic would be whmcs disable the translation in the rss file for the pubdate at least, anyway....we are full of "workarounds" with whmcs 🙂

Thanx Brian!

Share this post


Link to post
Share on other sites

the only other way I could think of would be to abandon using the announcementsRSS PHP feed and write a custom PHP RSS script (or 2 if you need separate Eng/Spa feeds) - that will put you in complete control of the output and should fix this issue.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated