I recently purchased a lifetime subscription to formidable and I am impressed with what you have done. Is it possible to create a custom registration form that links information to wordpress?
This isn't built in, but you can do so with a little custom code. It would look like this:
add_action('frm_after_create_entry', 'custom_update_user', 20, 2); function custom_update_user($entry_id, $form_id){ $user_id = wp_create_user($_POST['item_meta'][25], $_POST['item_meta'][26], $_POST['item_meta'][27]); //replace 25 with the login/screenname field, 26 with the password, 27 with the email update_user_meta('first_name', $_POST['item_meta'][28]); //replace 25 with the id of the first name field. optional }
(If not using WP 3.0 change update_user_meta to update_usermeta)
11:19 am June 29, 2010
Saul Fontenot-Amedee
3
Thank you so much! Let me make sure I understand.Here are the steps I hear…
create a form with desired inputs
add the code you have given me where?…
change my registration links to go to the form
Did I miss anything? Where do I insert the code you provided?
Yep, you've got it right. You can either add this code to your theme functions.php or create a new plugin for it. To use it as a registration page, it would probably also be good to add some screenname validation.
add_filter('frm_validate_field_entry', 'validate_frm_screenname', 20, 3); function validate_frm_screenname($errors, $field, $value){ //replace 25 with the screenname field id if((int)$field->id == 25 and !empty($value) and username_exists( $value )) $errors['field'.$field->id] = 'That username already exists.'; return $errors; }
This can go wherever you add the first bit. If you need to add any more validation, you can add it inside this function as well.
11:35 am July 1, 2010
Saul
5
So I am a little lost. Here is what I think I am setting up name=username and the email willl also go to the email field on the registration form. Will wordpress automatically generate a password for them or must I create an enter password field? Also where do I find the id for an input feild?
thanks for all your help
Saul
11:37 am July 1, 2010
Saul
6
Also 'custom_update_user', 20, 2); the 20 and the 2 are static and I do not change these values?
The WordPress username/login doesn't have spaces and is at least 4 characters long (I think). There is a way to get an automatic password, but this code doesn't include it. You could do a little research on how to automatically create a password in WordPress, or just add a password field so users can set their own password.
The field id for the first few fields is shown on the "Formidable" -> "Pro Form Entries" page at the top of each column. (I've moved this to the "Field Options" box for the next release.) You can find the ID for other fields by going to a custom display and select the field in question from the drop-down above the content box.
In 'custom_update_user', 20, 2); the 20 is the order the function is fired in and 2 is the number of variables passed to the function ($entry_id, $form_id).
1:32 pm July 5, 2010
elucia
8
Hi Steph,
I am also trying to create a registration/membership page where the User creates a log-in (their email) and password.
QUESTION: how do I
"….just add a password field so users can set their own password."??
QUESTION: What is the relevance of this part of your explanation? Are we supposed to insert field IDs somewhere in the code? (sorry I am newbie at setting up registration/membership):
The field id for the first few fields is shown on the "Formidable" -> "Pro Form Entries" page at the top of each column. (I've moved this to the "Field Options" box for the next release.) You can find the ID for other fields by going to a custom display and select the field in question from the drop-down above the content box.
Thanks so much for your help. I LOVE FormidablePro but I wish I knew more about what this plug in can do (I don't know what a lot of your pulldowns/options mean, or what they do.) Do you have a manual or step by step, or, samples with step by step? I'm sure you're really busy so most likely not, but it doesn't hurt to ask!!!
and I am a FormidablePro user (elucia is my username)
thank you so much!!
2:56 pm July 5, 2010
elucia
10
Steph,
When I add this code to my themefunctions.php file (at the bottom, before the "?>" field:
add_action('frm_after_create_entry', 'custom_update_user', 20, 2); function custom_update_user($entry_id, $form_id){ $user_id = wp_create_user($_POST['item_meta'][25], $_POST['item_meta'][26], $_POST['item_meta'][27]); //replace 25 with the login/screenname field, 26 with the password, 27 with the email update_usermeta('first_name', $_POST['item_meta'][28]); //replace 25 with the id of the first name field. optional } add_filter('frm_validate_field_entry', 'validate_frm_screenname', 20, 3); function validate_frm_screenname($errors, $field, $value){ //replace 25 with the screenname field id if((int)$field->id == 25 and !empty($value) and username_exists( $value )) $errors['field'.$field->id] = 'That username already exists.'; return $errors; }
I get the following error:
Fatal error: Call to undefined function wp_create_user() in /nfs/www/WWW_pages/leafvine/winebuythecaseclub.com/wp-content/themes/Builder/functions.php on line 122
Fatal Error
The theme has encountered a problem that it cannot recover from. Please use the following information to try to resolve the problem.
Error Code:
php_code_error:1:/nfs/www/WWW_pages/leafvine/winebuythecaseclub.com/wp-content/themes/Builder/functions.php:122:Call to undefined function wp_create_user()
Message:
A fatal code error occurred.
If you are unable to fix this problem, please copy all the text on this screen and send it to support@ithemes.com.
Debug Data:
Theme
I removed the code and all is back to normal but still would like to know how to make this registration/log-in form work.
thanks again!
9:35 am July 6, 2010
Saul Fontenot-Amedee
11
Hey Steph,
When I insert the first code it crashes my site with an error after I try to fill our the form
Fatal error: Call to undefined function wp_create_user() in /home/donor/public_html/boldergiving/site/wp-content/themes/k2/functions.php on line 21
I added a feild for the user to enter there own password. I used the name feild to create the username. That code goes at the top of the snipet.
Saul
2:35 pm July 6, 2010
elucia
15
ok thank you, Saul I'll check it out
2:35 pm July 6, 2010
elucia
16
ok thank you, Saul I'll check it out
3:57 pm August 2, 2010
sara
17
So Saul & Elusia, did you get this working? I am attempting this now.
8:41 am August 9, 2010
mgostick
18
I want to do this also, but when I insert this code into either the function.php or action.php file (i am using suffusion theme) I get a white screen when I refresh page of both website and backend. ASny clues? This would be a really useful function to have,and it would begreat to have a line by line guide if possible!
This is not a modification that should be attempted by unexperienced developers. This is a pretty complex addition, and there is a lot of validation that should be added for this to be stable once functional. This is not a feature I am currently supporting, so you're on your own with any issues you may have.
That said, here is some basic code that will need modification and additions. This code assumes you have two forms: one for registration, and one for editing the profile.
it would probably be easier to just have two separate forms: one for signup, and one for editing the profile. In the form you create for editing the profile, you can use dynamic values:
User Email: [email]
User Login: [login]
User Display Name: [display_name]
User First Name: [first_name]
User Last Name: [last_name]
//Registration Code add_action('frm_after_create_entry', 'custom_update_user', 20, 2); function custom_update_user($entry_id, $form_id){ require_once(ABSPATH . WPINC . '/registration.php'); $user_id = wp_create_user($_POST['item_meta'][25], $_POST['item_meta'][26], $_POST['item_meta'][27]); //replace 25 with the login/screenname field, 26 with the password, 27 with the email update_user_meta($user_id, 'first_name', $_POST['item_meta'][25]);//replace 25 with the id of the first name field. optional }
//Duplicate Entry Validation add_filter('frm_validate_field_entry', 'validate_frm_screenname', 20, 3); function validate_frm_screenname($errors, $field, $value){ require_once(ABSPATH . WPINC . '/registration.php'); //replace 25 with the screenname field id if((int)$field->id == 25 and !empty($value) and username_exists( $value )) $errors['field'.$field->id] = 'That username already exists.'; return $errors; }
//Profile Page and Update pages add_action('frm_after_update_entry', 'custom_update_profile', 25); function custom_update_profile($entry_id){ $user_id = $_POST['item_meta'][40]; //replace 40 with the id of the hidden user id field in your edit profile form update_user_meta($user_id, 'first_name', $_POST['item_meta'][25]);//replace 25 with the id of the first name field }
When you are adding code, your screen will turn white if you have a fatal error. You either need to watch your error log or open you wp-config.php and turn on debug mode with the line:
define('WP_DEBUG', true);
5:16 am August 10, 2010
mgostick
20
Steph
Thanks for your rapid reply. Like the earlier guys, I think this is a great plug-in, which is why we are trying to use it outside the box. Thanks for helping.
What I am missing as a piece of information is where (into which files) to put this code. I am happy to do this, but uncertain where – I agree with you about the two forms approach, but when for example you say profile page and update page code – which file do i add this codt too?