MyBB Community Forums

Full Version: Create two different ways of register (one requiring custom profile field, other not)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I asked this in general support forum but I solved by myself, so I think here would be more useful. So, here, the tuto.

Example of use:
You have your forum configured with several additional profile data in register (name, surname, telephone, address, etc) and additional profile data is required in new registers. Let us say that the people that fill these fields go to a group called VIP.

Also, you need to have another simple register form, without no profile data required, just like traditional registers with only username, email and password, so the people that use this form go to another group called Register and not VIP

The solution that I found maybe it's not the best option because involves modifying, or better said, adding some stuff to the core.

1) First of all, we need to have 2 member.php.
So, we copy one and rename it to member_users.php, this is the one that we are going to modify, not the other!

2) After that, we go in member_users.php to the following line (112):

require_once MYBB_ROOT."inc/datahandlers/user.php";
rename to
require_once MYBB_ROOT."inc/datahandlers/user_withoutprofile.php";

3) Then, we must copy the inc/datahandlers/user.php and paste it in:
inc/datahandlers/user_withoutprofile.php

No modify or delete inc/datahandlers/user.php!!

4) Now go to this line (675) in member_users.php

if($profilefield['required'] == 1) { ....}

Comment or delete the whole if.

5) Go to inc/datahandlers/user_withoutprofile.php , search for

function verify_profile_fields()

Comment all the code except return true; Like so:

function verify_profile_fields(){

return true;

}

5) Ok, now we have 2 ways of register. One asking for several custom fields that are required and other way of register that doesn't ask for anything excepto nickname, password.


6) In order to give to the user the choice to register in one way or other, lets modify template member_register_agreement and add another form.

The end of the template should be similar to this:
<div align="center">

<input type="hidden" name="step" value="agreement" />
<input type="hidden" name="action" value="register" />
<input type="submit" class="button" name="agree" value=" I agree. Register as VIP " />
</form>



<form action="member_users.php" method="post">
<input type="hidden" name="step" value="agreement" />
<input type="hidden" name="action" value="register" />
<input type="submit" class="button" name="agree" value="I agree. Register as user." />
</form>

</div>
{$footer}
</body>
</html>


[Image: 1YH5STE.jpg]

Note that in the second form we have modify from members.php to member_users.php (the one that doest not ask for additional profile data).

7) We must go to member_register template , rename it to member_register_user (rename will create one new) and modify only when appears member.php for member_users.php

8) Finally, in member_users.php, line 17 and 781 change member_register for member_register_user (carefull with replace all, only the complete words not replace member_register_XXXX!!!)


These would be the result

[Image: 4dQhnzHl.jpg]
[Image: 7rjSqmal.jpg]

As I said, this process implies modifying some stuff in core functionality (but you can revert it easily). I am not responsible for what may happen. It works well for me.
Hope it helps for someone!
Regards