I'm wondering what you mean by the custom form? Would I be able to add fields other than username and password? For example, I'd like to require Name and Organization. Am I able to do this with Theme My Login and if so how?
I'm wondering what you mean by the custom form? Would I be able to add fields other than username and password? For example, I'd like to require Name and Organization. Am I able to do this with Theme My Login and if so how?
I added these fields to register-form.php and put that into my plugins directory. I also created theme-my-login-custom.php to my theme directory with the code below. Not working. Fields show up on register page but hangs when submit. Theme My Login pop up note seemed to infer that a Custom Form option was now part of the plugin settings...
---
<?php
function tml_registration_errors( $errors, $user_login ) {
// Require "my-field"
if ( empty( $_POST['first_name'] ) )
$errors->add( 'empty_first_name', __( '"First Name" is a required field!' ) );
if ( empty( $_POST['last_name'] ) )
$errors->add( 'empty_last_name', __( '"Last Name" is a required field!' ) );
if ( empty( $_POST['organization'] ) )
$errors->add( 'empty_organization', __( '"Company | Organization" is a required field!' ) );
}
add_action( 'registration_errors', 'tml_registration_errors', 10, 2 );
// Finally, this function will save the posted field to the user meta table
function tml_new_user_registered( $user_id ) {
if ( isset( $_POST['first_name'] ) )
update_user_meta( $user_id, 'first_name', $_POST['first_name'] );
if ( isset( $_POST['last_name'] ) )
update_user_meta( $user_id, 'last_name', $_POST['last_name'] );
if ( isset( $_POST['organization'] ) )
update_user_meta( $user_id, 'organization', $_POST['organization'] );
}
add_action( 'tml_new_user_registered', 'tml_new_user_registered' );
?>
If you are using the User Moderation module, you will need to use the user_register hook instead of tml_new_user_registered.
I'm not using the User Moderation module. Any other ideas?
Just noticed where you said you placed theme-my-login-custom.php. It belongs in wp-content/plugins.
Sorry. Checked (I said it backwards above) and it is in wp-content/plugins and register-form.php is in the child theme directory.
This topic has been closed to new replies.