Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: MESWEB on April 13, 2015, 04:14:14 PM

Title: When You are login show popup once!
Post by: MESWEB on April 13, 2015, 04:14:14 PM
I need php code to place in template which one show popup box once.
Title: Re: When You are login show popup once!
Post by: Sir Osis of Liver on April 13, 2015, 10:33:20 PM
Do you want to show the popup once after every login, or once to each member on first login but not future logins?
Title: Re: When You are login show popup once!
Post by: Shambles on April 14, 2015, 04:00:29 AM
I use a single-instance popup when a member opens a certain type of topic (based on topic title content).

I use $_SESSION[..] to ensure the member only receives the popup once per session.

Maybe this could give you an idea where you want to go...?


<?php
if (
strpos(strtolower($context['subject']),'nsfw') > -1 && !isset($_SESSION['topicwarnnsfw'.$context['current_topic']]))
{
echo '<script type="text/javascript">
alert("WARNING\n\nThis topic may contain material that\n'
.
'is not suitable for viewing at work (NSFW)")
                     </script>'
;
$_SESSION['topicwarnnsfw'.$context['current_topic']] = true;
}
Title: Re: When You are login show popup once!
Post by: margarett on April 14, 2015, 05:23:52 AM
^^ This :)

Depending on what you want to do (a detailed explanation always helps ;) ) you can also do it in another way.

You have pretty much 2 types of logins:
"manual login" where you are prompted for username and password
"auto login" where you logged in via your cookie

If you only want to do it when someone *manually* logs in, you can hack LogInOut.php to add that "trigger", probably after
// You've logged in, haven't you?
updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']));


What Shambles gave you was a JavaScript alert box. It also depends on what kind of "popup" you want to have. If it's something like the "You have new PM" popup", it's a different approach...
Title: Re: When You are login show popup once!
Post by: MESWEB on April 14, 2015, 03:50:16 PM
Quote from: Krash on April 13, 2015, 10:33:20 PM
Do you want to show the popup once after every login, or once to each member on first login but not future logins?
Yes only after every login. Is there any mod to doing this? If not please help me with php code. Just simple box with x button to close.