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.
Custome message for Banned user
Re: Custome message for Banned user
Any ideas, anyone?
Re: Custome message for Banned user
Hi,
you can try this:
in hooks/__global.php set:
in login.php change
to
Please remember that the login.php will be overwritten when you recreate your files.
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");
}
Code: Select all
<?php if($_GET['loginFailed']) { ?>
<div class="alert alert-danger"><?php echo $Translation['login failed']; ?></div>
<?php } ?>
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 } ?>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Custome message for Banned user
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.
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
Hi Bruce,
sorry, pls use
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 } ?>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Custome message for Banned user
Hi Pascal,
Unfortunately that is returning an error:
( ! ) Parse error: syntax error, unexpected '{' in C:\wamp64\www\farmrex\login.php on line 6
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
Hi Bruce,
sorry, there is a missing )
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 } ?>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Custome message for Banned user
Thanks Pascal. Works perfect.