<?php
ob_start();
error_reporting(0);
$wpdb->hide_errors(); nocache_headers();
global $userdata; get_currentuserinfo();
 
if(!empty($_POST['action'])){
 
	require_once(ABSPATH . 'wp-admin/includes/user.php');
	require_once(ABSPATH . WPINC . '/registration.php');
 
	check_admin_referer('update-profile_' . $user_ID);
 
	$errors = edit_user($user_ID);
 
	if ( is_wp_error( $errors ) ) {
		foreach( $errors->get_error_messages() as $message )
			$errmsg = "$message";
	}
 
	if($errmsg == '')
	{
		do_action('personal_options_update',$user_ID);
		$d_url = $_POST['dashboard_url'];
		wp_redirect( get_option("siteurl").'?page_id='.$post->ID.'&updated=true' );
	}
	else{
		$errmsg = '<div class="box-red">' . $errmsg . '</div>';
		$errcolor = 'style="background-color:#FFEBE8;border:1px solid #CC0000;"';
 
	}
}
 
get_header(); 
 
get_currentuserinfo();
?>
		<div id="container-user-form">
<form  class="form-user-edit" name="profile" action="" method="post" enctype="multipart/form-data">
  <?php wp_nonce_field('update-profile_' . $user_ID) ?>
  <input type="hidden" name="from" value="profile" />
  <input type="hidden" name="action" value="update" />
  <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
  <input type="hidden" name="dashboard_url" value="<?php echo get_option("dashboard_url"); ?>" />
  <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />
 
	<?php if ( isset($_GET['updated']) ):
$d_url = $_GET['d'];?>
	
	  <div style="color: #FF0000; text-align:center; width:100%; margin-bottom:30px; padding-top:30px; font-size: 18px;">Votre profile a bien &eacute;t&eacute; mis &agrave; jour</div>
	
	<?php elseif($errmsg!=""): ?>
    
		  <span style="color: #FF0000; font-size: 11px;"><?php echo $errmsg;?></span>
	
	<?php endif;?>
	
		<h2>Mon profil</h2>
	
    
   
	  <label style=" line-height:50px;">Nom d'utilisateur</label>
	 <input type="text" name="user_login" id="user_login" value="<?php echo $userdata->user_login ?>" disabled="disabled" style="width: 300px; color:#999999;" />
      <div class="clear"></div><span style="margin-left:40px;  font-size:12px; font-style:italic; color:#CC3300;">Le nom d'utilisateur ne peut pas &ecirc;tre modifi&eacute;</span><br /><br />


	  <label>Pseudonyme<span style="color: #F00">*</span></label>
	 
      <input name="nickname" type="text" id="nickname" value="<?php the_author_meta( 'nickname', $current_user->id ); ?>" style="width: 300px;"/>
	
	
    
	  <label>Civilit&eacute;</label>
	<input  name="civ" type="text" id="civ" value="<?php the_author_meta( 'civ', $current_user->id ); ?>" style="width: 300px;"/>
	
	
	 <label>Pr&eacute;nom</label>
	  <input type="text" name="first_name" id="first_name" value="<?php echo $userdata->first_name ?>" style="width: 300px;" />
	
	
	  <label>Nom </label>
	  <input type="text" name="last_name" class="mid2" id="last_name" value="<?php echo $userdata->last_name ?>" style="width: 300px;" />
	
 
	  <label>Nom &agrave; afficher publiquement</label>
	 
      <select name="display_name" id="display_name">
					<?php
						$public_display = array();
						$public_display['display_nickname']  = $current_user->nickname;
						$public_display['display_username']  = $current_user->user_login;
						if ( !empty($current_user->first_name) )
							$public_display['display_firstname'] = $current_user->first_name;
						if ( !empty($current_user->last_name) )
							$public_display['display_lastname'] = $current_user->last_name;
						if ( !empty($current_user->first_name) && !empty($current_user->last_name) ) {
							$public_display['display_firstlast'] = $current_user->first_name . ' ' . $current_user->last_name;
							$public_display['display_lastfirst'] = $current_user->last_name . ' ' . $current_user->first_name;
						}
						if ( !in_array( $current_user->display_name, $public_display ) )// Only add this if it isn't duplicated elsewhere
							$public_display = array( 'display_displayname' => $current_user->display_name ) + $public_display;
						$public_display = array_map( 'trim', $public_display );
						foreach ( $public_display as $id => $item ) {
					?>
						<option id="<?php echo $id; ?>" value="<?php echo esc_attr($item); ?>"<?php selected( $current_user->display_name, $item ); ?>><?php echo $item; ?></option>
					<?php
						}
					?>
					</select>
     
	
	
	  <label>Email <span style="color: #F00">*</span></label>
	  <input type="text" name="email" class="mid2" id="email" value="<?php echo $userdata->user_email ?>" style="width: 300px;" />
	
	
	  <label>Nouveau mot de passe</label>
	 <input type="password" name="pass1" class="mid2" id="pass1" value="" style="width: 300px;" />

	
	  <label>Comfirmer le mot de passe</label>
	  <input type="password" name="pass2" class="mid2" id="pass2" value="" style="width: 300px;" />
	
    
	
	  <br /><span style="color: #F00">*</span> <span style="padding-right:60px;">Champs obligatoire</span>
	
	<h1>Informations Compl&eacute;mentaires</h1>
	
   
		<label>Rue</label>
		<input type="text" name="rue" id="rue" value="<?php echo esc_attr( get_the_author_meta( 'rue', $userdata->ID ) ); ?>" style="width: 300px;" />
	
	
		<label>Ville</label>
		<input type="text" name="ville" id="ville" value="<?php echo esc_attr( get_the_author_meta( 'ville', $userdata->ID ) ); ?>" style="width: 300px;" />
	
	
	
	
		<label>Code postal</label>
		<input type="text" name="code" id="code" value="<?php echo esc_attr( get_the_author_meta( 'code', $userdata->ID ) ); ?>" style="width: 300px;" />
	
    
	
		<label>Pays</label>
		<input type="text" name="pays" id="pays" value="<?php echo esc_attr( get_the_author_meta( 'pays', $userdata->ID ) ); ?>" style="width: 300px;" />
	
		<label>T&eacute;l&eacute;phone</label></td>
		<input type="text" name="phone" id="phone" value="<?php echo esc_attr( get_the_author_meta( 'phone', $userdata->ID ) ); ?>" style="width: 300px;" />
	
   
		<label>Portable</label>
		<input type="text" name="gsm" id="gsm" value="<?php echo esc_attr( get_the_author_meta( 'gsm', $userdata->ID ) ); ?>" style="width: 300px;" />
	
    
		<label>N&deg; entreprise ou TVA Intra </label></td>
		<input type="text" name="tva" id="tva" value="<?php echo esc_attr( get_the_author_meta( 'tva', $userdata->ID ) ); ?>" style="width: 300px;" />
	
    
		<label>Fax</label>
		<input type="text" name="fax" id="fax" value="<?php echo esc_attr( get_the_author_meta( 'fax', $userdata->ID ) ); ?>" style="width: 300px;" />

   
		<label>Skype</label>
		<input type="text" name="skype" id="skype" value="<?php echo esc_attr( get_the_author_meta( 'skype', $userdata->ID ) ); ?>" style="width: 300px;" />

   
		<label>Site Web</label>
		<input  name="url" type="text" id="url" value="<?php the_author_meta( 'url', $userdata->ID ); ?>" style="width: 300px;" />
	
		<label>Facebook URL</label></td>
		<input type="text" name="facebook" id="facebook" value="<?php echo esc_attr( get_the_author_meta( 'facebook', $userdata->ID ) ); ?>" style="width: 300px;" />
	
	
		<label>Twitter</label>
		<input type="text" name="twitter" id="twitter" value="<?php echo esc_attr( get_the_author_meta( 'twitter', $userdata->ID ) ); ?>" style="width: 300px;" />
	
    <h1>Renseignements biographiques</h1>
	
		<label>&Agrave; propos de Vous</label>
		<textarea class="text-input" name="description" id="description" rows="8" cols="30" ><?php echo the_author_meta( 'description', $userdata->ID ); ?></textarea>

	  <input  class="submit-profile" type="submit" value="Mettre &agrave; jour" />
	
  
        
  <input type="hidden" name="action" value="update" />
</form>
</div><!-- #container profile -->   
