Post Data to clr_user table through front end
-
Hello all,
I have been having trouble getting a function to work. I have manually added custom fields to clr_user. I want to be able to update the fields from the edit user page. I have gotten the fields and correct values to show up on the pages. I cannot get the data to update. I have two fields ‘databaseid’ (not the user_id: ties to a different app)and ‘companyid’. I realize now I should have put these in the metadata table. But, there are in the user table for now. The following is my code:/**addextra user fields*/ add_action( 'show_user_profile', 'my_show_extra_profile_fields' ); add_action( 'edit_user_profile', 'my_show_extra_profile_fields' ); if ( current_user_can( 'manage_options' ) ) { function my_show_extra_profile_fields( $user ) { ?> <h3>Extra profile information</h3> <table class="form-table"> <tr> <th><label for="databaseid"><?php _e('SSOID') ?></label></th> <td><input type="text" name="databaseid" id="databaseid" value="<?php echo esc_attr($user->databaseid) ?>" class="regular-text" /></td> </tr> <tr> <th><label for="companyid"><?php _e('Company ID') ?></label></th> <td><input type="text" name="companyid" id="companyid" value="<?php echo esc_attr($user->companyid) ?>" class="regular-text" /></td> </tr> </table> <?php }} else {} /**save extra user fields*/ 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 ) ) { wp_update_user(array('ID'=> $user_id, 'databaseid' => $_POST['databaseid'])); wp_update_user(array('ID'=> $user_id, 'companyid' => $_POST['companyid'])); } else {return false;} }
The last part wp_update_user is the portion that won’t work. I need the values to update upon submit. The rest of the code works as intended. I’ve looked through a ton of examples, tried dozens of variations with wp_update_user and update_metadata, but nothing will work. Again, I am not writing to the metadata table. I am writing to the user table.
- The topic ‘Post Data to clr_user table through front end’ is closed to new replies.