<?php
// profile

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

function my_save_extra_profile_fields( $user_id ) {

	if ( !current_user_can( 'edit_user', $user_id ) )
		return false;

	/* Copy and paste this line for additional fields. Make sure to change 'twitter' to the field ID. */
	update_usermeta( $user_id, 'twitter', $_POST['twitter'] );
	update_usermeta( $user_id, 'url', $_POST['url'] );
	update_usermeta( $user_id, 'skype', $_POST['skype'] );
	update_usermeta( $user_id, 'nickname', $_POST['nickname'] );
	update_usermeta( $user_id, 'facebook', $_POST['facebook'] );
	update_usermeta( $user_id, 'rue', $_POST['rue'] );
	update_usermeta( $user_id, 'ville', $_POST['ville'] );
	update_usermeta( $user_id, 'code', $_POST['code'] );
	update_usermeta( $user_id, 'pays', $_POST['pays'] );
	update_usermeta( $user_id, 'phone', $_POST['phone'] );
	update_usermeta( $user_id, 'gsm', $_POST['gsm'] );
	update_usermeta( $user_id, 'fax', $_POST['fax'] );
	update_usermeta( $user_id, 'description', $_POST['description'] );
	update_usermeta( $user_id, 'civ', $_POST['civ'] );
	update_usermeta( $user_id, 'agree', $_POST['agree'] );
	update_usermeta( $user_id, 'tva', $_POST['tva'] );
}
//affichage


add_action( 'personal_options', 'add_profile_options');
function add_profile_options( $profileuser ) {
    $civ = get_user_meta($profileuser->ID, 'civ', true);
    ?><tr>
    <th scope="row">Civilit&eacute;</th>
    <td><input type="text" name="greeting" value="<?php echo $civ; ?>" /></td>
    </tr><?php
}



// Add/Remove Contact Methods
function add_remove_contactmethods( $contactmethods ) {
	// $contactmethods['agree'] = 'C.G.U accepter: ';
	$contactmethods['civ'] = 'civile';
	$contactmethods['last_name'] = 'Nom';
	$contactmethods['first_name'] = 'Pr&eacute;nom';
	$contactmethods['nickname'] = 'Pseudonyme';
	$contactmethods['rue'] = 'Rue';
	$contactmethods['ville'] = 'Ville';
	$contactmethods['code'] = 'Code postal';
	$contactmethods['pays'] = 'Pays';
	$contactmethods['phone'] = 'T&eacute;l&eacute;phone';
	$contactmethods['tva'] = 'Entreprise ou TVA Intra';
	$contactmethods['gsm'] = 'Portable';
	$contactmethods['fax'] = 'Fax';
	$contactmethods['skype'] = 'Skype';
	$contactmethods['twitter'] = 'Twitter';
	$contactmethods['facebook'] = 'Facebook';
	
	

	// Remove Contact Methods
	unset($contactmethods['aim']);
	unset($contactmethods['yim']);
	unset($contactmethods['jabber']);
	

	return $contactmethods;
}
add_filter('user_contactmethods','add_remove_contactmethods',10,1);



//hides the personal options
function hide_personal_options(){
echo "\n" . '<script type="text/javascript">jQuery(document).ready(function($) {
$(\'form#your-profile > h3:first\').hide();
$(\'form#your-profile > table:first\').hide();
$(\'form#your-profile\').show();
 
$(\'label[for=url], input#url\').show();
});
 
</script>' . "\n";
}
add_action('admin_head','hide_personal_options');
