Jump to the post that solved this thread.
Solved: 3 Years, 4 Weeks ago Make custom profile field unique
#1
Solved: 3 Years, 4 Weeks ago
I want to make some custom profile field unique so that there will be no duplicated ones. Furthermore, This field is only at registration, required and not edible by the user.
Reply
#2
Solved: 3 Years, 4 Weeks ago
Unsure what you're trying to do here. So you don't want users to have the same answer for the custom profile field or am I wrong?
Plugin Count: I lost count.
Public Plugins are available here.
Official GitHub.
Please do not PM me for support unless asked to.
Reply
#3
Solved: 3 Years, 4 Weeks ago
You need to edit member.php, probably at line 260 after CAPTCHA verification. The code roughly should be:

$unique_id = $db->escape_string($mybb->get_input('some_id')); // 'some_id' is form input field name

// target_id is database column name
$query = $db->query("
	SELECT target_id
	FROM ".TABLE_PREFIX."users
	WHERE target_id='{$unique_id}'
");
if($db->num_rows($query) > 0)
{
	$errors[] = "Provided {$some_id} is already in use!"; // $some_id is Field name description (example: 'discord username')
}

Note:
Code not tested but should work.
You need to make sure the desired column in users table exists and the form input field name and database column name are correct.
Reply
#4
Solved: 3 Years, 4 Weeks ago
Even though, profile fields stored in userfields and i fixed query, It doesn't work. I checked and unique_id variable has no value so i think $mybb->get_input is not catching user input. input field name was profile_fields[fid1]

Well, I did it myself. I used core mybb's user array to catch profile field.
Reply
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)