为 new_form 注册用户表单添加一个新FLIED

FUNCTION.PHP

 

function my_show_extra_profile_fields( $user ) { ?>

<h3>Extra profile information</h3>

<tableclass=”form-table”>

<tr>

<th><labelfor=”twitter”>type client</label></th>

<td>

<selectname=”typeclient”>

<optionvalue=”Producteurs”>Producteurs</option>

<optionvalue=”Transporteurs”>Transporteurs</option>

<optionvalue=”Acheteurs”>Acheteurs</option>

</select>

<spanclass=”description”>Please enter client type.</span>

</td>

</tr>

</table>

<?php }

add_action( ‘user_register’, ‘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, ‘typeclient’, $_POST[‘typeclient’] );

}

Leave a Comment