Custom Account Tab Data Overwritten
-
Hello,
I have created a custom tab for some of the custom fields that are on my registration field. The fields work as expected except if i make any changes to the main account tab. If i make and changes to my name or email it wipes out the data in the other tab. If i only update the data in the custom tab then everything works as expected. Here is a video of what it does:
https://drive.google.com/file/d/1x1ggJ4XzSfzgyMkwTyx0_BkyX0B_HPYt/view?usp=sharing
Below is the code that i am using:/* add custom tab for facility info */ add_filter('um_account_page_default_tabs_hook', 'my_custom_tab_in_um2', 100 ); function my_custom_tab_in_um2( $tabs ) { $tabs[801]['orginfo']['icon'] = 'um-icon-medkit'; $tabs[801]['orginfo']['title'] = 'Agency/Facility Information'; $tabs[801]['orginfo']['submit_title'] = 'Update Agency/Facility Information'; $tabs[801]['orginfo']['custom'] = true; return $tabs; } /* make our new tab hookable */ add_action('um_account_tab__orginfo', 'um_account_tab__orginfo'); function um_account_tab__orginfo( $info ) { global $ultimatemember; extract( $info ); $output = $ultimatemember->account->get_tab_output('orginfo'); if ( $output ) { echo $output; } } /* Finally we add some content in the tab */ add_filter('um_account_content_hook_orginfo', 'um_account_content_hook_orginfo'); function um_account_content_hook_orginfo( $output ){ ob_start(); ?> <div class="um-field"> <?php $id = um_user('ID'); $output = ''; $names = array('title_position','office_phone','mobile_phone','Facility_Name','facility_legal_name','facility_main_phone','facility_24_7_phone','facility_address','facility_address_2','facility_county','facility_website','aspr_type','cms_type'); $fields = array(); foreach( $names as $name ) $fields[ $name ] = UM()->builtin()->get_specific_field( $name ); $fields = apply_filters('um_account_secure_fields', $fields, $id); foreach( $fields as $key => $data ) $output .= UM()->fields()->edit_field( $key, $data ); ?> </div> <?php $output .= ob_get_contents(); ob_end_clean(); return $output; } add_action('um_account_pre_update_profile', 'getUMFormData', 100); function getUMFormData(){ $id = um_user('ID'); $names = array('title_position','office_phone','mobile_phone','Facility_Name','facility_legal_name','facility_main_phone','facility_24_7_phone','facility_address','facility_address_2','facility_county','facility_website','aspr_type','cms_type'); foreach( $names as $name ) update_user_meta( $id, $name, $_POST[$name] ); }
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
The topic ‘Custom Account Tab Data Overwritten’ is closed to new replies.