A way to deny names that are already in use?

Forum
Last Post
Threads / Messages

GeneticAlpha

Loving Mysidia!
Member
Joined
May 24, 2020
Messages
203
Points
18
Age
28
Location
Tennessee
Mysidian Dollar
12,607
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?
 

Hall of Famer

Administrator
Staff member
Administrator
Joined
Dec 15, 2008
Messages
4,502
Points
48
Location
United States
Mysidian Dollar
213,747
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,162
Messages
32,369
Members
1,528
Latest member
XD_Stones
BETA

Latest Threads

Top