Index: extensions/user_custom_fields/admin.php
===================================================================
--- extensions/user_custom_fields/admin.php	(revision 31534)
+++ extensions/user_custom_fields/admin.php	(revision 31541)
@@ -163,5 +163,5 @@
         if (isset($_GET['hide'])) {
             check_input_parameter('hide', $_GET, false, PATTERN_ID);
-            $query = 'UPDATE ' . UCF_TABLE . ' SET active = 0 WHERE id_ucf=' . $_GET['hide'] . ';';
+            $query = 'UPDATE ' . UCF_TABLE . ' SET active = 0 , obligatory = 0 WHERE id_ucf=' . $_GET['hide'] . ';';
             pwg_query($query);
         }
Index: extensions/user_custom_fields/admin.tpl
===================================================================
--- extensions/user_custom_fields/admin.tpl	(revision 31534)
+++ extensions/user_custom_fields/admin.tpl	(revision 31541)
@@ -57,4 +57,6 @@
           jQuery('#pphide'+id).hide();
           jQuery('#ppshow'+id).show();
+		  jQuery('#ppobligatorys'+id).hide();
+          jQuery('#ppobligatoryh'+id).show();
           jQuery('#iord_'+id).css("opacity","0.4");
 		  $('#edit_libinfo'+id).attr('data-hide', 0);
Index: extensions/user_custom_fields/include/function.inc.php
===================================================================
--- extensions/user_custom_fields/include/function.inc.php	(revision 31534)
+++ extensions/user_custom_fields/include/function.inc.php	(revision 31541)
@@ -27,4 +27,20 @@
 }
 
+function data_info_user($id_user=null,$id_ucf=NULL){
+$query = '
+    SELECT data
+    FROM ' . UCFD_TABLE;
+    $wa='WHERE';
+    if($id_user!=null){
+        $query .=' '.$wa.' id_user='.$id_user;$wa='AND';
+    }
+    if($id_ucf!=null){
+        $query .=' '.$wa.' id_ucf='.$id_ucf;$wa='AND';
+    }
+$query .= ';';
+return pwg_query($query);
+}
+
+
 /*Admin*/
 function tab_user_custom_fields($id_ucf=NULL){
Index: extensions/user_custom_fields/initprofile.php
===================================================================
--- extensions/user_custom_fields/initprofile.php	(revision 31541)
+++ extensions/user_custom_fields/initprofile.php	(revision 31541)
@@ -0,0 +1,93 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | User Custom Fields plugin for Piwigo                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2016 ddtddt                    http://temmii.com/piwigo/ |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+//add prefiter
+add_event_handler('loc_begin_profile', 'ucfPI', 95 );
+
+function ucfPI(){
+  global $template, $prefixeTable, $userdata;
+  $template->set_prefilter('profile_content', 'ucfPT');
+  $template->set_filename('ucf_profile_add', realpath(UCF_PATH.'ucf_profile_add.tpl'));
+  $template->assign_var_from_handle('UCF_PROFILE_ADD', 'ucf_profile_add');
+}
+
+function ucfPT($content, &$smarty){
+  $search = '/(<legend>{\'Registration).*({if \$ALLOW_USER_CUSTOMIZATION}
+  <fieldset>)/is';
+  return preg_replace($search, '{$UCF_PROFILE_ADD}'."\n".'{if $ALLOW_USER_CUSTOMIZATION}
+  <fieldset>', $content);
+ }
+
+add_event_handler('loc_begin_profile', 'ucfinitprofil');
+function ucfinitprofil(){
+  global $template, $prefixeTable, $userdata;
+ if (isset($userdata['id'])){ 
+  $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';"));
+	if($PAED['state'] == 'active'){
+		add_event_handler('AP_render_content', 'get_user_language_desc');
+		$template->assign('useED',1);
+    }else{
+        $template->assign('useED',0);
+    }
+  $tab_user_register=tab_user_custom_fields_register();
+  $template->assign('UCF_USERNAME',$userdata['username']);
+  $template->assign('UCF_EMAIL',$userdata['email']);
+  while ($info_users = pwg_db_fetch_assoc($tab_user_register)) {
+	
+	$d=data_info_user($userdata['id'],$info_users['id_ucf']);
+	$row = pwg_db_fetch_assoc($d);
+	$items = array(
+		'UCFID' => $info_users['id_ucf'],
+		'UCFWORDING' => trigger_change('AP_render_content', $info_users['wording']),
+		'UCFOBLIGATORY' => $info_users['obligatory'],
+		'UCFDATA' => $row['data'],
+	);
+	$template->append('add_uers_register', $items);
+  }
+ }
+}
+
+ 
+add_event_handler('save_profile_from_post', 'ucfPT2');
+function ucfPT2(){
+  global $prefixeTable,$userdata;
+  $profil_base_url = PHPWG_ROOT_PATH . '/profile.php';
+  foreach ($_POST['data'] AS $id_ucf => $data) {
+	$q = 'SELECT 1 FROM ' . UCFD_TABLE . ' WHERE id_user=' . $userdata['id'] . ' AND id_ucf=' . $id_ucf;
+	$test = pwg_query($q);
+	$row = pwg_db_fetch_assoc($test);
+	if (count($row) > 0){
+	  if ($data != ''){
+		$query = 'UPDATE ' . UCFD_TABLE . ' SET data="' . $data . '" WHERE id_user=' . $userdata['id'] . ' AND id_ucf=' . $id_ucf;
+		pwg_query($query);
+	  }else{
+		$query = 'DELETE FROM ' . UCFD_TABLE . ' WHERE id_user=' . $userdata['id'] . ' AND id_ucf=' . $id_ucf;
+		pwg_query($query);
+	  }
+	}else if ($data != ''){
+		$query = 'INSERT ' . UCFD_TABLE . '(id_user,id_ucf,data) VALUES (' . $userdata['id'] . ',' . $id_ucf . ',"' . $data . '");';
+		pwg_query($query);
+	}
+  }
+  redirect($profil_base_url);  
+}
+
+?>
Index: extensions/user_custom_fields/initregister.php
===================================================================
--- extensions/user_custom_fields/initregister.php	(revision 31534)
+++ extensions/user_custom_fields/initregister.php	(revision 31541)
@@ -26,11 +26,11 @@
   global $template;
   $template->set_prefilter('register', 'ucfIT');
-  $template->set_filename('ucf_profile_add', realpath(UCF_PATH.'ucf_profile_add.tpl'));
-  $template->assign_var_from_handle('UCF_PROFILE_ADD', 'ucf_profile_add');
+  $template->set_filename('ucf_register_add', realpath(UCF_PATH.'ucf_register_add.tpl'));
+  $template->assign_var_from_handle('UCF_REGISTER_ADD', 'ucf_register_add');
 }
 
 function ucfIT($content, &$smarty){
   $search = '/(<fieldset>).*(<\/fieldset>)/is';
-  return preg_replace($search, '{$UCF_PROFILE_ADD}', $content);
+  return preg_replace($search, '{$UCF_REGISTER_ADD}', $content);
 }
 
Index: extensions/user_custom_fields/ucf_profile_add.tpl
===================================================================
--- extensions/user_custom_fields/ucf_profile_add.tpl	(revision 31534)
+++ extensions/user_custom_fields/ucf_profile_add.tpl	(revision 31541)
@@ -1,43 +1,42 @@
-<fieldset>
-  <legend>{'Enter your personnal informations'|@translate}</legend>
+  <legend>{'Registration'|@translate}</legend>
+  <input type="hidden" name="redirect" value="{$REDIRECT}">
     <ul>
       {foreach from=$add_uers_register item=adduersregister}
 		{if $adduersregister.UCFID == 1}
 		  <li>
-			<span class="property">
-              <label for="login">* {'Username'|@translate}</label>
-			</span>
-			<input type="text" name="login" id="login" value="{$F_LOGIN}" >
+			<span class="property">{'Username'|@translate}</span>
+			{$UCF_USERNAME}
 		  </li>
 		{else if $adduersregister.UCFID == 2}
-		  <li>
+		 {if not $SPECIAL_USER}
+		   <li>
 			<span class="property">
-			  <label for="password">* {'Password'|@translate}</label>
+			  <label for="password">{'Password'|@translate}</label>
 			</span>
-			<input type="password" name="password" id="password" >
+			<input type="password" name="password" id="password" value="">
 		  </li>
 		  <li>
 			<span class="property">
-			  <label for="password_conf">* {'Confirm Password'|@translate}</label>
+			  <label for="use_new_pwd">{'New password'|@translate}</label>
 			</span>
-			<input type="password" name="password_conf" id="password_conf" >
+			<input type="password" name="use_new_pwd" id="use_new_pwd" value="">
 		  </li>
-		{else if $adduersregister.UCFID == 3}
 		  <li>
 			<span class="property">
-			  <label for="mail_address">{if $obligatory_user_mail_address}* {/if}{'Email address'|@translate}</label>
+			  <label for="passwordConf">{'Confirm Password'|@translate}</label>
 			</span>
-			<input type="email" {if $adduersregister.UCFOBLIGATORY==1}required{/if} name="mail_address" id="mail_address" value="{$F_EMAIL}" >
-			{if not $obligatory_user_mail_address}
-			  ({'useful when password forgotten'|@translate})
-			{/if}
+			<input type="password" name="passwordConf" id="passwordConf" value="">
 		  </li>
+		 {/if}
+		{else if $adduersregister.UCFID == 3}
+		 {if not $SPECIAL_USER} {* can modify password + email*}
+		  <li>
+			<span class="property">
+			<label for="mail_address">{'Email address'|@translate}</label>
+			</span>
+			<input type="text" name="mail_address" id="mail_address" value="{$UCF_EMAIL}">
+		  </li>
+		 {/if}
 		{else if $adduersregister.UCFID == 4}
-		  <li {if $adduersregister.UCFOBLIGATORY==1}style="display: none"{/if}>
-			<span class="property">
-			  <label for="send_password_by_mail">{'Send my connection settings by email'|@translate}</label>
-			</span>
-			<input type="checkbox" name="send_password_by_mail" id="send_password_by_mail" value="1" checked="checked">
-		  </li>
 		{else if}
 		  <li>
@@ -45,5 +44,5 @@
               <label for="login">{if $adduersregister.UCFOBLIGATORY==1}*{/if} {$adduersregister.UCFWORDING}</label>
 			</span>
-			<input type="text" {if $useED==1}placeholder="{'Use Extended Description tags...'|@translate}"{/if} {if $adduersregister.UCFOBLIGATORY==1}required{/if} name="data[{$adduersregister.UCFID}]" id="data[$adduersregister.UCFID]">
+			<input type="text" {if $useED==1}placeholder="{'Use Extended Description tags...'|@translate}"{/if} {if $adduersregister.UCFOBLIGATORY==1}required{/if} name="data[{$adduersregister.UCFID}]" id="data[{$adduersregister.UCFID}]" value="{$adduersregister.UCFDATA}">
 		  </li>
         {/if}
@@ -53,2 +52,3 @@
   </ul>
 </fieldset>
+
Index: extensions/user_custom_fields/ucf_register_add.tpl
===================================================================
--- extensions/user_custom_fields/ucf_register_add.tpl	(revision 31541)
+++ extensions/user_custom_fields/ucf_register_add.tpl	(revision 31541)
@@ -0,0 +1,54 @@
+<fieldset>
+  <legend>{'Enter your personnal informations'|@translate}</legend>
+    <ul>
+      {foreach from=$add_uers_register item=adduersregister}
+		{if $adduersregister.UCFID == 1}
+		  <li>
+			<span class="property">
+              <label for="login">* {'Username'|@translate}</label>
+			</span>
+			<input type="text" name="login" id="login" value="{$F_LOGIN}" >
+		  </li>
+		{else if $adduersregister.UCFID == 2}
+		  <li>
+			<span class="property">
+			  <label for="password">* {'Password'|@translate}</label>
+			</span>
+			<input type="password" name="password" id="password" >
+		  </li>
+		  <li>
+			<span class="property">
+			  <label for="password_conf">* {'Confirm Password'|@translate}</label>
+			</span>
+			<input type="password" name="password_conf" id="password_conf" >
+		  </li>
+		{else if $adduersregister.UCFID == 3}
+		  <li>
+			<span class="property">
+			  <label for="mail_address">{if $obligatory_user_mail_address}* {/if}{'Email address'|@translate}</label>
+			</span>
+			<input type="email" {if $adduersregister.UCFOBLIGATORY==1}required{/if} name="mail_address" id="mail_address" value="{$F_EMAIL}" >
+			{if not $obligatory_user_mail_address}
+			  ({'useful when password forgotten'|@translate})
+			{/if}
+		  </li>
+		{else if $adduersregister.UCFID == 4}
+		  <li {if $adduersregister.UCFOBLIGATORY==1}style="display: none"{/if}>
+			<span class="property">
+			  <label for="send_password_by_mail">{'Send my connection settings by email'|@translate}</label>
+			</span>
+			<input type="checkbox" name="send_password_by_mail" id="send_password_by_mail" value="1" checked="checked">
+		  </li>
+		{else if}
+		  <li>
+			<span class="property">
+              <label for="login">{if $adduersregister.UCFOBLIGATORY==1}*{/if} {$adduersregister.UCFWORDING}</label>
+			</span>
+			<input type="text" {if $useED==1}placeholder="{'Use Extended Description tags...'|@translate}"{/if} {if $adduersregister.UCFOBLIGATORY==1}required{/if} name="data[{$adduersregister.UCFID}]" id="data[{$adduersregister.UCFID}]">
+		  </li>
+        {/if}
+	  {/foreach}
+
+
+  </ul>
+</fieldset>
