Jump to content

Display a message only to members who use exact domain email


Maxxius

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...