Advertisement:

Author Topic: LoginOut.php - help to make another condition at the login  (Read 648 times)

Offline Bakuto

  • Newbie
  • *
  • Posts: 4
LoginOut.php - help to make another condition at the login
« on: June 03, 2019, 06:00:08 PM »
Hello. I want to make another condition after the user pressed login button.
On the user profile i added a custom field (checkbox).
I need to check if this checkbox is checked or not.

My problem : i can't make a correct querry and can't select id_member...

Here is my code, but i dont know where i need to place it on LoginOut.php
In function Login 2 () only ? after ?
Code: [Select]
$user_settings = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);

Code: [Select]
$username = $_POST['user'];

$sql = $smcFunc['db_query']('','
SELECT
p.id_member, p.value, mem.id_member, mem.member_name
FROM {db_prefix}themes AS p
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = p.id_member)
WHERE p.variable = "cust_checkbox"
AND mem.id_member = "$username"'
);

while ($result = $smcFunc['db_fetch_assoc']($sql)) {
$smcFunc['db_free_result']($sql);

if ($result['value'] === 1) {
header('Location: login_condition.php');
}
}

Offline Bakuto

  • Newbie
  • *
  • Posts: 4
Re: LoginOut.php - help to make another condition at the login
« Reply #1 on: June 04, 2019, 04:00:59 AM »
i tested it and didn't work ...

Code: [Select]
$sql = $smcFunc['db_query']('', '
SELECT value
FROM {db_prefix}themes
WHERE id_member = {int:id_member}
AND variable = "cust_checkbox"',
array(
'id_member' => $user_info['id'],
)
);
if ($smcFunc['db_num_rows']($sql) == 1)
$context['cust_login'] = true;
return;

and i added in LoginTemplate.php in the template_login() function :

Code: [Select]
if (!empty($context['cust_login'])) {
echo "This is the test";
}

and this echo appears with the login form. i need it after, when the user has clicked on the login button.
any idea  where i need to place my code ?