Page 1 of 1
Custome message for Banned user
Posted: 2020-08-22 03:54
by bruceholt
I am trying to set a custom message that if a user is banned for whatever reason, that a custom message displays instead of "Your previous login attempt failed. Try again." that is in the language file.
I still need the original message in case the user has entered wrong username or password.
I have searched files that I think it might be in but cannot see a mention of banned.
Re: Custome message for Banned user
Posted: 2020-08-29 21:51
by bruceholt
Any ideas, anyone?

Re: Custome message for Banned user
Posted: 2020-09-01 20:21
by pbottcher
Hi,
you can try this:
in hooks/__global.php set:
Code: Select all
function login_failed($attempt, &$args){
$banned=sqlvalue("SELECT isBanned from membership_users where memberID='".$attempt['username']."'");
if ($banned) redirect("index.php?loginFailed=2");
}
in login.php change
Code: Select all
<?php if($_GET['loginFailed']) { ?>
<div class="alert alert-danger"><?php echo $Translation['login failed']; ?></div>
<?php } ?>
to
Code: Select all
<?php if($_GET['loginFailed']==2) { ?>
<div class="alert alert-danger"><?php echo 'PUT YOUR MESSAGE FOR BANNED USERS HERE'; ?></div>
<?php } else { ?>
<div class="alert alert-danger"><?php echo $Translation['login failed']; ?></div>
<?php } ?>
Please remember that the login.php will be overwritten when you recreate your files.
Re: Custome message for Banned user
Posted: 2020-09-02 09:25
by bruceholt
Hi Pascal,
The message works beautifully when the user is banned but when signing in and out (for a user that is not banned) it shows the default message "Your previous login attempt failed. Try again." all of the time.
Re: Custome message for Banned user
Posted: 2020-09-02 11:10
by pbottcher
Hi Bruce,
sorry, pls use
Code: Select all
<?php if($_GET['loginFailed']==2) { ?>
<div class="alert alert-danger"><?php echo 'PUT YOUR MESSAGE FOR BANNED USERS HERE'; ?></div>
<?php } elseif($_GET['loginFailed']==1 { ?>
<div class="alert alert-danger"><?php echo $Translation['login failed']; ?></div>
<?php } ?>
Re: Custome message for Banned user
Posted: 2020-09-03 09:13
by bruceholt
Hi Pascal,
Unfortunately that is returning an error:
( ! ) Parse error: syntax error, unexpected '{' in C:\wamp64\www\farmrex\login.php on line 6
Re: Custome message for Banned user
Posted: 2020-09-03 10:56
by pbottcher
Hi Bruce,
sorry, there is a missing )
Code: Select all
<?php if($_GET['loginFailed']==2) { ?>
<div class="alert alert-danger"><?php echo 'PUT YOUR MESSAGE FOR BANNED USERS HERE'; ?></div>
<?php } elseif($_GET['loginFailed']==1) { ?>
<div class="alert alert-danger"><?php echo $Translation['login failed']; ?></div>
<?php } ?>
Re: Custome message for Banned user
Posted: 2020-09-04 09:40
by bruceholt
Thanks Pascal. Works perfect.