Steven Frasier

Forum Replies Created

Viewing 15 posts - 16 through 30 (of 36 total)
  • Author
    Posts
  • in reply to: Duplicate Organizers Meta Section With Different Header #1408131
    Steven Frasier
    Participant

    Got it. If it’s of any use to you or anyone else, here is the working code:

    <?php
    /**
     * Single Event Meta (Organizer) Template
     *
     * Override this template in your own theme by creating a file at:
     * [your-theme]/tribe-events/modules/meta/organizer.php
     *
     * @package TribeEventsCalendar
     * @version 4.4
     */
    
    ?>
    
    <div class="tribe-events-meta-group tribe-events-meta-group-organizer">
    	<h3 class="tribe-events-single-section-title"><?php echo "Organizers"; ?></h3>
    	<dl>
    		
    	<?php	$posts = get_field('the_organizers');?>
    	
    	<?php foreach( $posts as $p ): // variable must NOT be called $post (IMPORTANT) ?>
    	    <dt style="display:none;"><?php // This element is just to make sure we have a valid HTML ?></dt>
    			<dd class="tribe-organizer">
    	    	<a href="<?php echo get_permalink( $p->ID ); ?>"><?php echo get_the_title( $p->ID ); ?></a>
    	    	<?php the_field('author', $p->ID); ?>
    	    </dd>
    	<?php endforeach; ?>
    	
    	<?php do_action( 'tribe_events_single_meta_organizer_section_end' ); 
    		?>
    	</dl>
    </div>
    in reply to: Duplicate Organizers Meta Section With Different Header #1405989
    Steven Frasier
    Participant

    I created a new template file from scratch and tried again. Still just outputting “Array” with this template file coding:

    <?php
    
    $field_name = "the_organizers";
    $field = get_field_object($field_name);
    
    ?>
    
    <div class="tribe-events-meta-group tribe-events-meta-group-organizer">
    	<h3 class="tribe-events-single-section-title"><?php echo "Organizers"; ?></h3>
    	<dl>
    		<?php
    		do_action( 'tribe_events_single_meta_organizer_section_start' );
    		
    		
    		echo $field;
    	
    	
    	do_action( 'tribe_events_single_meta_organizer_section_end' );
    		?>
    	</dl>
    </div>

    Screenshot attached as well.

    in reply to: Duplicate Organizers Meta Section With Different Header #1405733
    Steven Frasier
    Participant

    Is there any chance you could tell me why this is only outputting “array” on the frontend (attempting to use ACF)? As you can see, I basically copied the Organizer template. I then added the call to grab the template to meta.php

    <?php
    /**
     * Single Event Meta (Organizer) Template
     *
     * Override this template in your own theme by creating a file at:
     * [your-theme]/tribe-events/modules/meta/organizer.php
     *
     * @package TribeEventsCalendar
     * @version 4.4
     */
    
    $organizer_ids = tribe_get_organizer_ids();
    $multiple = count( $organizer_ids ) > 1;
    
    $phone = tribe_get_organizer_phone();
    $email = tribe_get_organizer_email();
    $website = tribe_get_organizer_website_link();
    ?>
    
    <div class="tribe-events-meta-group tribe-events-meta-group-organizer">
        <h3 class="tribe-events-single-section-title"><?php echo "Organizers"; ?></h3>
        <dl>
            <?php
            do_action( 'tribe_events_single_meta_organizer_section_start' );
    
            /*
    *  Get a field object and display it with it's value
    */
    
    $field_name = "onlyorganizer";
    $field = get_field_object($value);
    $value = get_field( "onlyorganizer" );
    
    echo $value['label'] . get_field( "onlyorganizer") . $field['value'];
    
            do_action( 'tribe_events_single_meta_organizer_section_end' );
            ?>
        </dl>
    </div>

    Here is the exported php of the field group via ACF:

    if( function_exists('acf_add_local_field_group') ):
    
    acf_add_local_field_group(array(
        'key' => 'group_5a26fec4071a0',
        'title' => 'speaker organizer',
        'fields' => array(
            array(
                'key' => 'field_5a26ff1a9337b',
                'label' => 'onlyorganizer',
                'name' => 'onlyorganizer',
                'type' => 'post_object',
                'instructions' => '',
                'required' => 0,
                'conditional_logic' => 0,
                'wrapper' => array(
                    'width' => '',
                    'class' => '',
                    'id' => '',
                ),
                'post_type' => array(
                    0 => 'tribe_organizer',
                ),
                'taxonomy' => array(
                ),
                'allow_null' => 1,
                'multiple' => 1,
                'return_format' => 'object',
                'ui' => 1,
            ),
        ),
        'location' => array(
            array(
                array(
                    'param' => 'post_type',
                    'operator' => '==',
                    'value' => 'tribe_events',
                ),
            ),
            array(
                array(
                    'param' => 'post_type',
                    'operator' => '==',
                    'value' => 'tribe_organizer',
                ),
            ),
        ),
        'menu_order' => 0,
        'position' => 'normal',
        'style' => 'default',
        'label_placement' => 'top',
        'instruction_placement' => 'label',
        'hide_on_screen' => '',
        'active' => 1,
        'description' => '',
    ));
    
    endif;
    in reply to: Duplicate Organizers Meta Section With Different Header #1405498
    Steven Frasier
    Participant

    Jennifer,

    Thank you so much for the comprehensive response! The effort you guys put in for support is peerless. Unfortunately, I may not have been clear:

    I am strictly attempting to add this meta section to the Events Calendar Pro single event view — I am not working with the Community Events add-on at all.

    That said, I’m diving into the ACF documentation now. Still, ideally I find a way to achieve this via PHP and without forcing myself to rely on the potentially variable compatibility of another another plugin.

    I’ll keep you posted in regard to any progress! Thanks so much.

    in reply to: Duplicate Organizers Meta Section With Different Header #1405038
    Steven Frasier
    Participant

    Hmm..is it really that complicated? I was hoping that it would be as simple as being pointed to the necessary portion of the template file (details.php and /modules/organizers.php) that I could duplicate and change the header output on the frontend.

    What about Advanced Custom Fields? Going this route, would I use the relational “Post Object” field type, or something else? I was able to get the meta field to display on the backend (and even select from the organizers custom post type), but can you or anyone else direct me toward a decent tutorial on how to get ACF relational field data to display in the meta event details section of the single event view? My attempt at adding get_field(‘organizersonly’) resulted in “empty” despite having selected organizers on the backend.

    in reply to: Duplicate Organizers Meta Section With Different Header #1400262
    Steven Frasier
    Participant

    Upon re-reading my topic, I just want to clarify the goal noted in my first paragraph.

    Speakers and Organizers don’t necessarily have to be differentiated on the backend, per se, just available to be selected under two different meta sections/headers. Ideally, they pull from the same custom “Organizers” post type that comes with The Events Calendar out of the box.

    in reply to: Where to Place acf_form_head() to Save Submitted Data #1366218
    Steven Frasier
    Participant

    Okay, thank you for everything, Cliff. I actually think my best option may be one that I have not mentioned—namely, Gravity Forms.

    Feel free to close the thread. You were tremendously helpful, no matter the result.

    in reply to: Where to Place acf_form_head() to Save Submitted Data #1365942
    Steven Frasier
    Participant

    Understood. Thank you again.

    The trouble is that I’m not sure Additional Fields functionality helps me achieve the more advanced form field options like “repeater fields” or even multi-line table-like fields where users input the data horizontally according to the field’s sub-labels up top. Please see screenshot for some clarity.

    Am I mistaken?

    in reply to: Backend Integration of Advanced Custom Fields #1365708
    Steven Frasier
    Participant

    Hi Andras,

    A fellow dev came up with this snippet.

    It was unsuccessful—at least the way I implemented it, within my theme’s functions.php—but I’m wondering if that offers you any clues.

    If it’s any help..

    Here is my /community/edit-event.php:

    <?php
    /**
     * Event Submission Form
     * The wrapper template for the event submission form.
     *
     * Override this template in your own theme by creating a file at
     * [your-theme]/tribe-events/community/edit-event.php
     *
     * @since    3.1
     * @version  4.5
     *
     * @var int|string $tribe_event_id
     */
     
    if ( ! defined( 'ABSPATH' ) ) {
        die( '-1' );
    }
     
    if ( ! isset( $tribe_event_id ) ) {
        $tribe_event_id = null;
    }
     
    ?>
     
    <?php tribe_get_template_part( 'community/modules/header-links' ); ?>
     
    <?php do_action( 'tribe_events_community_form_before_template', $tribe_event_id ); ?>
     
    <form method="post" enctype="multipart/form-data" data-datepicker_format="<?php echo esc_attr( tribe_get_option( 'datepickerFormat', 0 ) ); ?>">
        <input type="hidden" name="post_ID" id="post_ID" value="<?php echo absint( $tribe_event_id ); ?>"/>
        <?php wp_nonce_field( 'ecp_event_submission' ); ?>
     
        <?php tribe_get_template_part( 'community/modules/title' ); ?>
     
        <?php tribe_get_template_part( 'community/modules/description' ); ?>
         
        <?php tribe_get_template_part( 'community/modules/acf' ); ?>
     
        <?php tribe_get_template_part( 'community/modules/datepickers' ); ?>
     
        <?php tribe_get_template_part( 'community/modules/image' ); ?>
     
        <?php tribe_get_template_part( 'community/modules/taxonomy', null, array( 'taxonomy' => Tribe__Events__Main::TAXONOMY ) ); ?>
     
        <?php tribe_get_template_part( 'community/modules/taxonomy', null, array( 'taxonomy' => 'post_tag' ) ); ?>
     
        <?php tribe_get_template_part( 'community/modules/venue' ); ?>
     
        <?php tribe_get_template_part( 'community/modules/spam-control' ); ?>
     
        <?php tribe_get_template_part( 'community/modules/submit' ); ?>
    </form>
     
    <?php do_action( 'tribe_events_community_form_after_template', $tribe_event_id ); ?>

    And here is the template for the ACF field group I created at community/modules/acf:

    <?php acf_form( $options );
        $settings = array(
      'id' => 'acf-group_59dd13c80be9e',
      'form' => false
    );
    acf_form($settings);
                 
    ?>
    in reply to: Where to Place acf_form_head() to Save Submitted Data #1365690
    Steven Frasier
    Participant

    Cliff,

    I can’t even begin to express how much I appreciate the time and hard work you put into writing that snippet, but unfortunately the front end CE form is still failing to retain or save any of the data input into the ACF fields.

    I have attached a screenshot to show you where I placed the snippet within my theme’s function.php file.

    I see the notes within the snippet stating “This will get ACF loaded but you will need to add your own additional code to get ACF to do anything at all on the Community Events forms.”

    Is this for other people who use the snippet in the future? The ACF form group is displaying on the front-end form, it just will not save any of the data entered into the ACF fields. Once I hit submit, the content for ACF fields is gone. (For what it’s worth, the data saves when it is input via Admin edit event.)

    I have disabled all plugins with the exception of my theme, all Events Calendar-related plugins and the ACF Pro plugin.

    If it’s any help..

    Here is my /community/edit-event.php:

    <?php
    /**
     * Event Submission Form
     * The wrapper template for the event submission form.
     *
     * Override this template in your own theme by creating a file at
     * [your-theme]/tribe-events/community/edit-event.php
     *
     * @since    3.1
     * @version  4.5
     *
     * @var int|string $tribe_event_id
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	die( '-1' );
    }
    
    if ( ! isset( $tribe_event_id ) ) {
    	$tribe_event_id = null;
    }
    
    ?>
    
    <?php tribe_get_template_part( 'community/modules/header-links' ); ?>
    
    <?php do_action( 'tribe_events_community_form_before_template', $tribe_event_id ); ?>
    
    <form method="post" enctype="multipart/form-data" data-datepicker_format="<?php echo esc_attr( tribe_get_option( 'datepickerFormat', 0 ) ); ?>">
    	<input type="hidden" name="post_ID" id="post_ID" value="<?php echo absint( $tribe_event_id ); ?>"/>
    	<?php wp_nonce_field( 'ecp_event_submission' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/title' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/description' ); ?>
    	
    	<?php tribe_get_template_part( 'community/modules/acf' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/datepickers' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/image' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/taxonomy', null, array( 'taxonomy' => Tribe__Events__Main::TAXONOMY ) ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/taxonomy', null, array( 'taxonomy' => 'post_tag' ) ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/venue' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/spam-control' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/submit' ); ?>
    </form>
    
    <?php do_action( 'tribe_events_community_form_after_template', $tribe_event_id ); ?>
    

    And here is the template for the ACF field group I created at community/modules/acf:

    <?php acf_form( $options );
    	$settings = array(
      'id' => 'acf-group_59dd13c80be9e',
      'form' => false
    );
    acf_form($settings);
    			
    ?>
    in reply to: Where to Place acf_form_head() to Save Submitted Data #1364969
    Steven Frasier
    Participant

    Cliff,

    Unfortunately, I’m not exactly clear about the instructions.

    Are you suggesting I add acf_form_head(), using that method, to the same Event_Form.php file?

    Is this the correct code? Where within the file should it be placed? I sincerely apologize for all of the confusion.

    if (
    	is_community_page( 'acf_form_head()' )
    		)
    
    add_action('wp_head', 'acf_form_head()');
    in reply to: Where to Place acf_form_head() to Save Submitted Data #1364645
    Steven Frasier
    Participant

    Hey Cliff,

    Very much appreciate that, but it did not work, at least not the way I implemented it (as seen in attached screenshot).

    If it’s any help, here is a thread that includes additional ideas and information from my discussion with a dev for Advanced Custom Fields.

    I have also tried changing my calendar template to Default Page, as well as Default Events Page, adding acf_form_head() above the get_header(); function that exists in both with no luck.

    screenshot

    in reply to: Backend Integration of Advanced Custom Fields #1363235
    Steven Frasier
    Participant

    Thanks again, Andras,

    Unfortunately I’m getting mostly the same from them. They have helped get me this far, and provided the same line you provided, but they aren’t sure where the appropriate ‘get_header()’ would appear in the TEC/CE template files.

    Do you have any idea where I might begin to look? Which template files contain ‘get_header()’?

    Here is the last responses I received from them:

    f that’s the template, there are no hooks there that will help you. Like I said, you’d need to talk to the developers of that plugin to see if they provide any hooks that let you make changes. I am not familiar with that plugin at all and I cannot really help with that. The only part I can help you with is the acf_form call, it should look something like this

    $settings = array(
      'id' => 'acf-group_59dd13c80be9e',
      'form' => false
    );
    acf_form($settings);

    also, note that you’ll need to figure out how to modify the header to include the call to acf_form_head() that’s mentioned in the acf_form() documentation.

    I was able to get the form to display by adding the code he provided to my get-details.php file, per the Themer’s Guide.

    ACF will not save anything if you do not include the call to acf_form_head() before anything is output on the page.

    YOu can also add something like this that will work

    add_action('init', 'add_acf_form_head_to_entire_site');
    function add_acf_form_head_to_entire_site() {
      acf_form_head();
    }

    But where? Who would best know where the get_header() line exists pertaining to The Events Calendar / Community Events plugin?

    in reply to: Backend Integration of Advanced Custom Fields #1362800
    Steven Frasier
    Participant

    Hi Andras,

    Thanks for the detailed response!

    I was able to get the form to display on the user submission form on the front-end with the following code plugged into /wp-content/plugins/the-events-calendar-community-events/src/views/community/edit-event.php

    <?php
    /**
     * Event Submission Form
     * The wrapper template for the event submission form.
     *
     * Override this template in your own theme by creating a file at
     * [your-theme]/tribe-events/community/edit-event.php
     *
     * @since    3.1
     * @version  4.5
     *
     * @var int|string $tribe_event_id
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	die( '-1' );
    }
    
    if ( ! isset( $tribe_event_id ) ) {
    	$tribe_event_id = null;
    }
    
    ?>
    
    <?php tribe_get_template_part( 'community/modules/header-links' ); ?>
    
    <?php do_action( 'tribe_events_community_form_before_template', $tribe_event_id ); ?>
    
    <form method="post" enctype="multipart/form-data" data-datepicker_format="<?php echo esc_attr( tribe_get_option( 'datepickerFormat', 0 ) ); ?>">
    	<input type="hidden" name="post_ID" id="post_ID" value="<?php echo absint( $tribe_event_id ); ?>"/>
    	<?php wp_nonce_field( 'ecp_event_submission' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/title' ); ?>
    	
    	<?php acf_form( $options );
    	$settings = array(
      'id' => 'acf-group_59dd13c80be9e',
      'form' => false
    );
    acf_form($settings);
    			
    ?>
    
    	<?php tribe_get_template_part( 'community/modules/description' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/datepickers' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/image' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/taxonomy', null, array( 'taxonomy' => Tribe__Events__Main::TAXONOMY ) ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/taxonomy', null, array( 'taxonomy' => 'post_tag' ) ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/venue' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/organizer' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/website' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/custom' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/cost' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/spam-control' ); ?>
    
    	<?php tribe_get_template_part( 'community/modules/submit' ); ?>
    </form>
    
    <?php do_action( 'tribe_events_community_form_after_template', $tribe_event_id ); ?>
    

    Basically, I added the following acf_form call to edit-event.php (I’ll save it to the tribe-events folder on the production site once I get it working correctly):

    <?php acf_form( $options );
                    $settings = array(
      'id' => 'acf-group_59dd13c80be9e',
      'form' => false
    );
    acf_form($settings);
                                                   
    ?>

    I tested it, but at the moment it isn’t registering any of the data entered. It erases upon hitting submit, and isn’t sent via the notification email. So now I’m trying to look into that, before eventually tweaking the CSS to get the look right.

    Also, is this bit of advice from the ACF support forum relevant? If so, could you shed some light?

    Note that you’ll need to figure out how to modify the header to include the call to acf_form_head() that’s mentioned in the acf_form() documentation.

    According to their documentation, that’s what allows it to perform the logic needed to save the data.

    It is important to note that whilst the acf_form() function will create a form allowing you to input data, it will not perform the logic needed to save the data. This logic is handled by another function called acf_form_head(). To allow the form to save data, you will need to place the acf_form_head() function at the top of your page template before any HTML is rendered.

    Where would I add that?

    in reply to: Backend Integration of Advanced Custom Fields #1362264
    Steven Frasier
    Participant

    Absolutely—thanks Andras!

Viewing 15 posts - 16 through 30 (of 36 total)