Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember Tweaks › eMember – add custom field verification for registration
Tagged: registration process
- This topic has 9 replies, 4 voices, and was last updated 9 years ago by admin.
-
AuthorPosts
-
March 4, 2015 at 6:12 pm #12306JeremyMember
I created a custom field called “Registration Code” which I would like to compare to a database of codes and only allow the registration to work if there is a match. I need some help finding the registration processing code so I can add my own code to it? I was looking at emember_process_reg_form() in emember_registration_utils.php but not sure if this is the right place.
March 4, 2015 at 7:24 pm #68920wzpModeratorWould you still be using the email verification link to complete the registration?
What is the “big picture” point of what you’re trying to do; and why?
March 4, 2015 at 10:47 pm #68921JeremyMemberNo email verification link would be used for registration.
Client wants to have each of its reps to have a unique registration code that they can hand out to customers. Then when the customer registers they will enter this registration code in the registration form in a custom field called “Registration Code”. When they hit submit i want to compare the value of that code with a database of valid codes (which I will do custom code for). If the code is a valid code then I will allow them to register, if not then throw an error letting them know it is not a valid code.
So we want it so you have to have a valid registration code to register on the site so I need to know where to find the registration processing code is to add this custom code in.
March 5, 2015 at 12:03 am #68922adminKeymasterYeah it should be doable with some custom coding. Are you a good PHP developer?
There are probably couple of ways to go about it.
Check the custom registration code field’s value after the form is submitted then show an error is the code doesn’t match
OR
Use JavaScript to read the custom field’s value when the user clicks the “Register” button. You can use AJAX to send the data back to the server side to do a lookup. If it matches then you let the registration form to be submitted. Otherwise prevent the form submission and show an error.
The 2nd approach is probably going to be more elegant and you will be able to apply your custom code without modifying anything in the plugin.
March 5, 2015 at 8:52 pm #68923JeremyMemberI would prefer to do the check in php as I don’t want to rely on javascript for the form checking. I just need help in figuring out what php file I need to add my code checking to.
March 6, 2015 at 2:47 am #68924adminKeymasterLook in the following file:
wp-eMember/eMember_registration_utils.php
Search for the following line of code in that file. This is the code that gets executed when a registration form is submitted. You have all the info in the POST variable so you can read your custom field data and do stuff there.
if (isset($_POST['eMember_Register'])) {
March 6, 2015 at 4:17 pm #68925JeremyMemberThanks for pointing me to the right place. Do you know where I could locate the javascript error checking code for the registration form also? Figure I would add it for those using a browser that supports javascript. I will hunt around for it later today after I have finished up the php code but if you could point me to the right file it would save me time hunting for it.
Here is a test snippet of code for those looking for a code example that come across this post,
// Check if user entered a valid registration code
$reg_code = $_POST;
if ($reg_code !== “1234”) {
$output .= ‘<span class=”emember_error”>Bad registration code. Go back and retry your registration code.</span>’;
$emember_config->set_stacked_message(’emember_full_registration’, array(‘type’ => ‘warning’, ‘message’ => $output));
return;
}
March 6, 2015 at 10:15 pm #68926adminKeymasterThe javascript code you add from your custom script. You don’t need to modify anything in the plugin for it.
November 24, 2015 at 8:36 pm #68927rjarmonMemberDid you ever get this finished? If so, did you use the eMember database or a custom mySql database to contain the codes for verification? I’m fairly new to PHP and mySql, which is what I have been told to use to acheive the same goal.
My situation is a little different. We have a team (of 10,000+ and growing) that we want to limit access to. The team has already been assigned a random string of numbers from another system. I would like to use this same string of numbers to verify that they are indeed members of our team. I’ve already set up a mySql database with these numbers, but I’m a little unclear on how to get the eMember plugin to check the database and allow or deny account creation.
Any suggestions?
November 25, 2015 at 3:59 am #68928adminKeymasterIs any of the functions explained in the following documentation helpful?
https://www.tipsandtricks-hq.com/wordpress-membership/wp-emember-miscellaneous-tweaks-248
I really think that you may need to hire a developer (if you are not good with coding). This kind of customization is not something you can do without having really good coding skills.
-
AuthorPosts
- You must be logged in to reply to this topic.