Use the following code to add a custom user profile field to your website.
You can add it to your functions.php (via Code Snippets Plugin).
// add custom field to user profile function fs_add_custom_user_profile_fields( $user ) { ?> <h3><?php _e('Extra Profile Information', 'fs_custom'); ?></h3> <table class="form-table"> <tr> <th> <label for="odoo_customer_id"><?php _e('Odoo Customer ID', 'fs_custom'); ?></label> </th> <td> <input type="text" name="odoo_customer_id" id="odoo_customer_id" value="<?php echo esc_attr( get_the_author_meta( 'odoo_customer_id', $user->ID ) ); ?>" class="regular-text" /><br /> <span class="description"><?php _e('Please enter Odoo Customer ID.', 'fs_custom'); ?></span> </td> </tr> </table> <?php } function fs_save_custom_user_profile_fields( $user_id ) { if ( !current_user_can( 'edit_user', $user_id ) ) return FALSE; update_usermeta( $user_id, 'odoo_customer_id', $_POST['odoo_customer_id'] ); } add_action( 'show_user_profile', 'fs_add_custom_user_profile_fields' ); add_action( 'edit_user_profile', 'fs_add_custom_user_profile_fields' ); add_action( 'personal_options_update', 'fs_save_custom_user_profile_fields' ); add_action( 'edit_user_profile_update', 'fs_save_custom_user_profile_fields' );
Optionally, you can add this field to the back-end list of users too, in order to easily see the value of the field:
// Now let's add this field to the User list in the backend function new_modify_user_table( $column ) { $column['odoo_customer_id'] = 'Odoo Customer ID'; return $column; } add_filter( 'manage_users_columns', 'new_modify_user_table' ); function new_modify_user_table_row( $val, $column_name, $user_id ) { switch ($column_name) { case 'odoo_customer_id' : return get_the_author_meta( 'odoo_customer_id', $user_id ); break; default: } return $val; } add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );
This was meant to add a custom field titled “Odoo Customer ID” to the user profile back-end for admin purposes.
You would want to adjust any references to the “Odoo Customer ID” and update the field to be something other than “odoo_customer_id”.