• Resolved HawksDev

    (@kc9ryt)


    Hello,

    I have the custom tab that I have been working on for some time now and have noticed that the drop down fields are not storing the data into a serialized array and instead is just storing as a number. Is there something I need to change so that these fields are stored as serialized data? The fields that are storing incorrectly are facility_county, aspr_type, and cms_type.

    
    /* 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('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 );
    			echo 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 )
        if( isset( $_POST[$name] ) ){ 
    		update_user_meta( $id, $name, $_POST[$name] );
        }
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @kc9ryt

    The dropdown only saves the value that’s not serialized.

    If you’re using the multi-select, it will serialize the data.

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @kc9ryt

    …Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. 🙂

    Regards,

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Drop down values on custom tab not saving as serialized’ is closed to new replies.