• Resolved shadynicnack

    (@shadynicnack)


    I want to create a simple custom field for the register form called “Company”. The company I work for doesn’t have much money to use toward web applications, so we are trying to with do with much we can. I do love the Events Manager plugin very much. I have created some hooks to add a custom field to the register form directly from the admin. The text field shows up in the form just nicely, and was able to custom in the admin. It almost seems to work but in admin area I drag & drop the new created field which I called “Company” into table and this works as well. BUT I can not see this new created field’s content in my Booking form page.

    function bweb_add_custom_event_fields(){
    	?>
    		<p>
    			<label for='user_company'><?php esc_html_e('Company', 'textdomain'); ?></label>
    			<input type="text" name="user_company" id="user-company"  class="input" value="<?php if(!empty($_REQUEST['user_company'])) echo esc_attr($_REQUEST['user_company']); ?>" />
    		</p>
    
    	<?php
    }
    add_action('em_register_form','bweb_add_custom_event_fields');
    
    function  bweb_save_custom_event_fields (){
    	global $EM_Booking ;
    	if( ! empty( $_REQUEST['user_company'] ) ){
    			$EM_Booking->booking_meta['registration']['user_company'] = wp_kses( $_REQUEST['user_company'], array() );
    	}
    }
    add_filter('em_booking_add','bweb_save_custom_event_fields');	
    
    function bweb_table_custom_event_fields($template, $EM_Bookings_Table){
            $template['user_company'] = __('Company', 'textdomain');
            return $template;
    }
    add_action('em_bookings_table_cols_template', 'bweb_table_custom_event_fields',10,2);
    
    function bweb_display_col_custom_event_fields($val, $col, $EM_Booking, $EM_Bookings_Table, $csv){
            if( $col == 'user_company' ){
                    $val = $EM_Booking->get_person()->user_company;
            }
            return $val;
    }
    add_filter('em_bookings_table_rows_col','bweb_display_col_custom_event_fields', 10, 5);

    I am trying to figure why the contents is not showing up in the admin. Can you help on why and give me some advice to fix?

    https://wordpress.org/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    sorry for the confusion but can you clarify this please?

    BUT I can not see this new created field’s content in my Booking form page.

    also, are you using EMpro ?

    Thread Starter shadynicnack

    (@shadynicnack)

    In the admin, when I go to booking. I click on the gear which allows me to modify what I want to display. I then bring over my custom field name as example “Company” over to the side. Save the settings. It brings me back to the bookings page, and the title / header of “Company” shows up, but underneath it, the content doesn’t appear. As an example, they go and enter their company name into the field like Getco. But Getco doesn’t appear under the company name on the bookings page in the admin.

    I am trying to figure why the content is not showing up in the admin under the booking. I did this all hooks and technically it should work. Can you give me some advice why its not working and how to get it fix.

    And the answer to second question is no… I am not using EMpro. Trying to make a hook for one simple question.

    Is the field being saved correctly in the database?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cannot see created field in my Booking form page (From custom hook)’ is closed to new replies.