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">
<tr>
<th><label for="address"><?php _e("address",'shabatkeeper'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
<td>
<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>
</td>
</tr>
etc..
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
exit;
}
}
}
Maybe there is another short way to do it, so if u know let me know please.