Username check
#1
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?
Reply
#2
Bump please help!
Reply
#3
what if statement are you talking about? and what is a registrar request?
My Plugins: [1.8]|[1.6]

** Selling custom plugin that enables Bitcoin payments. PM me if interested in purchasing! **
Reply
#4
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"
Reply
#5
(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.
Reply
#6
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.
Reply
#7
(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
Reply
#8
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.
Reply
#9
(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.
Reply
#10
(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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)