I am making a username checking plugin. I want to know how to I deny a login if the the if statement is not true How do I deny it.
And If it is fine accept it. Also How do I make it check get it to listen for a registrar request?
what if statement are you talking about? and what is a registrar request?
If you want to deny a login you can hook "member_do_login_start", if you want yo deny a user registraron you can hook "member_do_register_start"
(2016-11-10, 08:46 AM)fizz Wrote: [ -> ]what if statement are you talking about? and what is a registrar request?
(2016-11-10, 01:32 PM)Neeeeeeeeeel.- Wrote: [ -> ]If you want to deny a login you can hook "member_do_login_start", if you want yo deny a user registraron you can hook "member_do_register_start"
<?php
if(!defined("IN_MYBB"))
{
die("You Cannot Access This File Directly. Please Make Sure IN_MYBB Is Defined.");
}
$plugins->add_hook('member_do_register_end', 'mcusernamecheck_actionRegister');
function mcusernamecheck_info()
{
return array(
"name" => "mcusernamecheck",
"description"=> "Check if username is a MC username",
"author" => "KingLinuxMC",
"version" => "1.0",
"guid" => "",
"compatibility" => "18*"
);
}
function mcusernamecheck_activate(){
global $db;
$mcusernamecheck_group = array(
'gid' => 'NULL',
'name' => 'mcusernamecheck',
'title' => 'MC Username check',
'description' => 'mcusernamecheck',
'disporder' => "1",
'isdefault' => "0",
);
}
function mcusernamecheck_actionRegister()
{
global $db, $lang, $user, $userhandler;
$user = $db->escape_string($mybb->input['user']);
$url = str_ireplace(
'{user}',
$user,
$options-$URT
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_AUTOREFERER => true,
CURLOPT_FAILONERROR => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => 'https://api.mojang.com/users/profiles/minecraft/{user}'
));
$response = curl_exec($curl);
curl_close($curl);
if ($response !== false) {
$response = json_decode($response, true);
if (!isset($response['name'])) {
}
}
}
?>
(2016-11-10, 01:32 PM)Neeeeeeeeeel.- Wrote: [ -> ]If you want to deny a login you can hook "member_do_login_start", if you want yo deny a user registraron you can hook "member_do_register_start"
But how do you make it deny? something.end();
I am a Java dev, php is not my thing.
error_no_permissions(); is a way to do it. But I think it's not the best in this case.
I do not fully understand what are you trying to achieve and why.
(2016-11-11, 01:04 AM)Neeeeeeeeeel.- Wrote: [ -> ]error_no_permissions(); is a way to do it. But I think it's not the best in this case.
I do not fully understand what are you trying to achieve and why.
Thx. I am trying to make a plugin that makes where the username must be a Minecraft username
Why not use error("Username taken.") instead? When you use that function you can at least tell the user why there was an error instead of just a general message.
(2016-11-11, 01:34 PM)dragonexpert Wrote: [ -> ]Why not use error("Username taken.") instead? When you use that function you can at least tell the user why there was an error instead of just a general message.
Definitely better. I didn't remember that something like that exists.
(2016-11-11, 01:34 PM)dragonexpert Wrote: [ -> ]Why not use error("Username taken.") instead? When you use that function you can at least tell the user why there was an error instead of just a general message.
I wish MyBB's Core used that function more often.