Announcement

  •  » Extensions
  •  » Issue with add_event_handler('login_success', 'show_popup');

#1 2017-08-16 00:59:52

cgcarter
Member
2017-08-09
14

Issue with add_event_handler('login_success', 'show_popup');

Hi Everyone,

I added some html to my theme's index.tpl:

<div id='abc'>
    <h2>Welcome to my site</h2>
    <p>Hello, welcome to my website.</p>
</div>

I have some CSS in the local files editor:

#abc {
  display: none;
}

Now here's the problem:In the PersonPlugin main.inc.php, I add this code and it does not work.  After login, it does not show the div.  The funny thing is that if I use 'init' instead of 'login_success', it works.:

add_event_handler('init', 'show_popup');
function show_popup() {

global $template;

$script_content = <<<EOT

document.getElementById('abc').style.display = "block";
 
EOT;
$template->block_footer_script(array('require' => 'jquery'), $script_content);
}

But I really need to show this popup after a login.  Any ideas about why this isn't working? 

Thanks in advance,
-Chris

Piwigo version: 2.9.1
PHP version: 5.6.30
MySQL version: 5.5.51-38.2

Offline

 

#2 2017-08-16 09:40:18

cgcarter
Member
2017-08-09
14

Re: Issue with add_event_handler('login_success', 'show_popup');

Hi all,

So, I resolved this issue, but not by getting 'login_success' to work.  I actually moved everything into what has become a rudimentary new plugin.  After doing this, I still tried to get 'login_success' to work, but no dice.  So I caught the event that signals the end of the index page load, and then tested to see if the $user[user_name] != 'guest', meaning someone is logged in.  This was sufficient to get the popup to present right after a login.  So I consider the issue fixed.

I also figured out how to do that preg_replace business so I could inject the HTML for this popup, rather than having it in the index.tpl already, which is obviously an imperative concept.  I mention it cuz I was having issue with it a few days ago in my other post.

So now on to the fun stuff - I need to hook this thing into the database.  Lol, here we go...

Offline

 

#3 2017-08-16 10:43:35

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: Issue with add_event_handler('login_success', 'show_popup');

Hi cgcarter,

cgcarter wrote:

So I caught the event that signals the end of the index page load, and then tested to see if the $user[user_name] != 'guest', meaning someone is logged in.

But ths problem here is that you logged in visitor will always see it, not only when they successfully logged in :-/

cgcarter wrote:

So now on to the fun stuff - I need to hook this thing into the database.  Lol, here we go...

The plugins have database connection. You just have to perform SQL queries if you need some.

Offline

 
  •  » Extensions
  •  » Issue with add_event_handler('login_success', 'show_popup');

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact