Field validation in wordpress registration form

<?php
/*
Plugin Name: Fields
Plugin URI: http://github.com/GreatDevelopers/suneha/tree/master/sunehaPlugin
Description: Description: Lets your wordpress website connect to suneha interface.
Author: Hitesh Sofat
Version: 1.0
Author URI: http://www.hiteshkumarsofat.com
*/
add_action('register_form','add_field');
function add_field()
{
$phone=(isset($_POST['phonenumber']))?$_POST['phonenumber']: '';

echo "”._e(‘Phone number’,’mydomain’).”
“;
}
add_filter(‘registration_errors’,’myform’,10,3);

//apply_filters( ‘registration_errors’, $errors, $sanitized_user_login, $user_email );
function myform($errors, $sanitized_user_login, $user_email)
{
if(empty($_POST[‘phonenumber’]))
$errors->add( ‘phone number’, __(‘ERROR: MUST BE ADD PHONE NUMBER’,’mydomain’) );
return $errors;
}
add_action(‘user_register’,’myplugin_user_register’);
function myplugin_user_register($user_id){
if(isset($_POST[‘phonenumber’]))
{
update_user_meta($user_id, ‘phonenumber’, $_POST[‘phonenumber’]);
}
}

?>

Advertisements

One Comment Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s