Jump to content

Display a message only to members who use exact domain email


Maxxius

Recommended Posts

Posted

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? 🙂

Posted

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"}

Posted

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";}}

?

 

Posted
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. 

Posted
{{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}}

 

Posted
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.

Archived

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

  • Recently Browsing   0 members

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