Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter jonmojo

    (@jonmojo)

    Thanks Herman (@bsfherman) – You mentioned ‘this doc’ for reference, but the link is missing :(. I’m guessing it’s something in the Media upload process?

    Thread Starter jonmojo

    (@jonmojo)

    OK – The following seems to work OK with multiple AFCE forms in the same Events Manager template (event-editor.php – copy to themes). The filter is in the root file of a plugin or functions.php in a theme.

    Of the above settings, turn ‘Save ACF fields’ OFF, everything else stays the same.

    An ACF or ACFE approach would probably better, using their own hooks, filters or settings, but this is working for me.

    function my_form_extras_post ($result, $event) {
    
    
    	if ( (!empty($_POST)) && (!is_admin()) ) {  //check for post variables and ignore if on the admin pages.
    		
    		//Will iterate over each ACF field held in $_POST and save it.
    		foreach ( $_POST['acf'] as $ec_field => $ec_field_value) {
    
    			$event_id = $event->post_id;						//post_id of the event ('550')
    			$field_key = $ec_field;								//The ACF field Key (field_dkjasflk2343)
    			$field_details = get_field_object($field_key);		//The ACF field detail - array
    			$field_name = $field_details['name'];				//The ACF name for the field ('company_name')
    			$field_value = $ec_field_value;						//The value in the field as typed in on the interface ('Truck Mart')
    
    			if ( !empty( $field_value ) ) {						//Do nothing if the value field is empty
    					update_post_meta( $event_id, $field_name , $field_value );  //Creates or updates the meta field holding the value
    					update_post_meta( $event_id, "_".$field_name, $field_key ); //Creates or updates the meta field holding the ACF reference (note the underscore before the name)
    			}
    		}
    	}
    
    }
    
    add_filter( 'em_event_save', 'my_form_extras_post', 10, 2 );

    • This reply was modified 2 years, 10 months ago by jonmojo.
    Thread Starter jonmojo

    (@jonmojo)

    Just an update to this. The key issue I’ve encountered is that that the post_id of the AFCE form does not match the post_id for the form it’s actually in (event_id). AFCE appears to be using the post_id for the ACF form it’s related to. I’ve tried to hook in to change this on submission, but I don’t think these work with the ‘Submit’ enabled in the form. For reference my setting are:

    • General:
      • Field group name
      • Action:
        • Update post
      • Save:
        • Target: current: post
        • Defaults
        • Save ACF Fields: All
      • Load:
        • Load values: Yes
        • Defaults
        • Save ACF Fields: All
    • Settings:
      • Form element: off
      • Submit button: off
      • Everything else: default
    • HTML, Validation, Success:
      • Default

    Of the Hooks, none that start ‘afce/form/submit’ trigger on submission of the event form and the same result with ‘acfe/form/prepare/post’ . I’ve also tried:

    <?php acfe_form(array(
    	'name' => 'basic-info',
    	'post_id' => $EM_Event->post_id,
    	)); ?>
    Thread Starter jonmojo

    (@jonmojo)

    OK – So this is kind of working, but:

    • The displayed calendar switches from Full to small.
    • The item is there (in the HTML), but other than hovering on the date number, there is no clear indication it’s there.
    • The date ‘scope’ argument(s) in the search set a default date range that is not needed (or too short). I can’t find the setting to change this.
    Thread Starter jonmojo

    (@jonmojo)

    I’ve worked this out by borrowing the code from em_events.php for the search:

    require_once WP_PLUGIN_DIR . '/events-manager/em-events.php';
    
    	$search_args = em_get_search_form_defaults();
    	$args['has_view'] = true; // prevent search from generating its own view container
    	$args['id'] = 12;
    	$search_args = em_get_search_form_defaults( $args, 'events' );
    	//remove date and category
    	em_locate_template('templates/events-search.php', true, array('args'=>$search_args));

    Note the addition of the $args[‘id’] = 12; This needs to match the id for the displayed events_list.
    Then set the ID of the events list [events_list id=12] – This currently requires the shortcode to be copied with an edit on line 114 (in em-shortcode.php)

    if( !empty($args['id']) ) $args['id'] = rand(100, getrandmax());
    to
    if( empty($args['id']) ) $args['id'] = rand(100, getrandmax());

    Just in case this helps anyone else. The Ajax/JQuery continues to work OK, so long as the ID’s for the search and Event list match.

    It’s probably useful to add the – add_action(‘plugins_loaded’, – to ensure Events Manager loads before running the code above.

    Note: This will currently only work for an event list on the page as the search code/call, above, will need to be altered to allow for Calendar-search & Events-search at the same time.

    Thread Starter jonmojo

    (@jonmojo)

    Thanks for this – I’m now trying to extend the Events Manager via a plugin to create a side-by-side calendar/list view with the search common to both elements, as a header. Is there a way to call just the search as a template part? I can call/copy the template easily enough (templates/templates/search.php), but I’m not clear how to pass it the $args.

    You may have a better approach to this?

    I’ll drop the views in as shortcodes.

    Thread Starter jonmojo

    (@jonmojo)

    Thread Starter jonmojo

    (@jonmojo)

    I see it creates its on post/event – Problem solved!

    Hi Mr Takayuki,

    I have also encountered this error in a ThemeForest Template (CitiLights – Real Estate WordPress Theme). Other plugins running:

    • WPBakery Visual Composer
    • Wordfence Security
    • Revolution Slider
    • Envato WordPress Toolkit
    • dsIDXpress

    Unfortunately the solution above, does not work for me. πŸ™

    Fatal error: Class ‘WPCF7_TagGenerator’ not found in /var/webs/Clients/bls/wp-content/plugins/contact-form-7/modules/text.php on line 190

    Cheers,

    Jon.

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