News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

When You are login show popup once!

Started by MESWEB, April 13, 2015, 04:14:14 PM

Previous topic - Next topic

MESWEB

I need php code to place in template which one show popup box once.

Sir Osis of Liver

Do you want to show the popup once after every login, or once to each member on first login but not future logins?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Shambles

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') > -&& !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;
}

margarett

^^ 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...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

MESWEB

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.

Advertisement: