A way to deny names that are already in use?

Forum
Last Post
Threads / Messages

GeneticAlpha

Loving Mysidia!
Member
Joined
May 24, 2020
Messages
283
Points
18
Age
30
Location
Tennessee
Mysidian Dollar
13,356
Is there a way for the system to check if there is a user with the same nickname or not and deny duplicates names to be used? I know it's possible, I just don't know how to set this up. Can anyone help me make this?
 
You mean duplicate nickname? Maybe at account settings, inside the method profile(), try to change this line:

PHP:
        if($mysidia->input->post("submit")){
            $mysidia->db->update("users_profile", array("avatar" => $mysidia->input->post("avatar"), "nickname" => $mysidia->input->post("nickname"), "gender" => $mysidia->input->post("gender"), "color" => $mysidia->input->post("color"), "bio" => $mysidia->input->post("bio"), "favpet" => $mysidia->input->post("favpet"), "about" => $mysidia->input->post("about")), "username = '{$mysidia->user->username}'");
            return;
        }

To:

PHP:
        if($mysidia->input->post("submit")){
            $nicknameExists = $mysidia->db->select("users_profile", ["nickname"], "nickname = '{$mysidia->input->post("nickname")}'")->fetchColumn();
            if($nicknameExists) throw new Exception("Nickname is already taken, please use a different one.");
            $mysidia->db->update("users_profile", array("avatar" => $mysidia->input->post("avatar"), "nickname" => $mysidia->input->post("nickname"), "gender" => $mysidia->input->post("gender"), "color" => $mysidia->input->post("color"), "bio" => $mysidia->input->post("bio"), "favpet" => $mysidia->input->post("favpet"), "about" => $mysidia->input->post("about")), "username = '{$mysidia->user->username}'");
            return;
        }

The code above assumes clean installation of Mys v1.3.5(the version you are using I believe). If you have modified the file and the method profile(), then you need to just add the nicknameExists check to where it fits in your customized code.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,267
Messages
33,049
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top