In the user profile page there is a site url text box.

  1. how can I adjust the site input field to required?

  2. how can I validate that it is true site?

1 Answer 1


What I did create form with fields and validate them: added this line of code to add the user knowledge that it is required fields

 <span class="description"><?php _e('(required)'); ?></span> 

added this to form like this:

add_action( 'show_user_profile', 'extra_user_profile_fields' );
add_action( 'edit_user_profile', 'extra_user_profile_fields' );

function extra_user_profile_fields( $user ) { ?>
<table class="form-table">
<th><label for="address"><?php _e("address",'shabatkeeper'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
<input type="text" name="address" id="address" value="<?php echo esc_attr( get_the_author_meta( 'address', $user->ID ) ); ?>" class="regular-text"  /><br />
<span class="description"><?php _e("Please enter your address.",'shabatkeeper'); ?>   </span>


then added a validate if it is empty and if empty do error msg:

add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );

function save_extra_user_profile_fields( $user_id ) {

if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }
  if (!isset($_POST['address']) || empty($_POST['address'])  {
      wp_die( __('Error: you must fill all fields') );

  } else {
      // field was set and contains a value
      // do your action


Maybe there is another short way to do it, so if u know let me know please.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.