Maxxius Posted January 9, 2020 Share Posted January 9, 2020 hi, I ran into a problem that a very popular email service used widely in my country 10-15 years ago went defunct and ~10% om my members have registered using that email provider which went belly up. I obviously can't email them but for those who still visit I need to get their attention with a big message to update their email. So what I'm basically looking for is a template code in which I would enter the message text, but what I have no idea how to formulate the code for the condition. so something like if user email is *@deadprovider.com then show the message. can anyone help me out? 🙂 Link to comment Share on other sites More sharing options...
Adriano Faria Posted January 9, 2020 Share Posted January 9, 2020 You would need a plugin/widget to select these members based on the email domain. Or you can try existing plugins available on marketplace to help you out: Link to comment Share on other sites More sharing options...
opentype Posted January 9, 2020 Share Posted January 9, 2020 Try this somewhere in a template: {{if \IPS\Member::loggedIn()->email}} {{$provider="@opentrash.com";}} {{$email=strtolower(\IPS\Member::loggedIn()->email);}} {{$length=strlen($email);}} {{$providerlength=strlen($provider);}} {{if $providerlength <= $length}} {{if substr($email,$length-$providerlength) == $provider}} You are doomed. {{endif}} {{endif}} {{endif}} Change the provider value to yours and change the “You are doomed” to what you wanna display. Can also be a Pages block call, e.g. {block="email-announcement"} Link to comment Share on other sites More sharing options...
Adriano Faria Posted January 9, 2020 Share Posted January 9, 2020 A tip: use mb_strtolower and mb_substr instead. Link to comment Share on other sites More sharing options...
Maxxius Posted January 9, 2020 Author Share Posted January 9, 2020 the code worked perfectly! Thank you @opentype & @Adriano Faria (btw I have seen all those mods earlier and none of them did exactly what I needed). and one question for the future, if I needed to add more email providers would the line look like this? {{$provider="@opentrash.com, @old.com, @defunct.com";}} ? Link to comment Share on other sites More sharing options...
Adriano Faria Posted January 9, 2020 Share Posted January 9, 2020 48 minutes ago, Maxxius said: and one question for the future, if I needed to add more email providers would the line look like this? You would need to create as array as use \in_array to check. Mobile device now. Can’t help you more than that. Sorry. Link to comment Share on other sites More sharing options...
Maxxius Posted January 13, 2020 Author Share Posted January 13, 2020 @opentype & @Adriano Faria perhaps you have any ideas how to make the code to check for more providers. Like {{$provider="@opentrash.com, @old.com, @defunct.com";}} Link to comment Share on other sites More sharing options...
newbie LAC Posted January 13, 2020 Share Posted January 13, 2020 {{if \IPS\Member::loggedIn()->email}} {{$providers = array('opentrash.com' 'old.com', 'defunct.com');}} {{$parts = explode('@', mb_strtolower(\IPS\Member::loggedIn()->email));}} {{$provider = array_pop($parts);}} {{if \in_array($provider, $providers)}} You are doomed. {{endif}} {{endif}} Link to comment Share on other sites More sharing options...
Maxxius Posted January 13, 2020 Author Share Posted January 13, 2020 4 hours ago, newbie LAC said: {{if \IPS\Member::loggedIn()->email}} {{$providers = array('opentrash.com' 'old.com', 'defunct.com');}} {{$parts = explode('@', mb_strtolower(\IPS\Member::loggedIn()->email));}} {{$provider = array_pop($parts);}} {{if \in_array($provider, $providers)}} You are doomed. {{endif}} {{endif}} something must be wrong here because I get this error when trying to save the exact template you posted here. The template bit contains broken PHP or template tags and could not be saved. Please review your modifications. Link to comment Share on other sites More sharing options...
Adriano Faria Posted January 13, 2020 Share Posted January 13, 2020 'opentrash.com' 'old.com', 'defunct.com' Missing comma after 'opentrash.com'. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.