Reputation: 27
I'm using the User plugin and I wanted to know how can I flash messages to the user when they login (new session) and logout.
Tried using this when a client logs in, but it doesn't make sense as it will always show up when the page is refreshed.
<p data-control="flash-message" data-interval="5" class="success">
{{message}}
</p>
Thanks
Upvotes: 0
Views: 894
Reputation: 259
Use the hooks/events
rainlab.user.login
: The user has successfully signed in.
rainlab.user.logout
: The user has successfully signed out.
Create a new Plugin with the builder
in the plugin.php write in the boot function:
Event::listen('rainlab.user.login', function($user) {
Flash::success(Successfully Logged in)
});
Event::listen('rainlab.user.logout', function($user) {
Flash::success(Successfully Logged out)
});
- dont change the vendor code because is a bad practice.
more to the events https://octobercms.com/docs/services/events
and to the list of the user events https://github.com/rainlab/user-plugin#events
Upvotes: 1