Venue url

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 9 years, 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17245

    Hello Stephen,
    I’m looking to add ‘Venue URL’ field to submission form. I’ve added this code to eo-event-form-event-venue.php:

    <label class="eo-fes-form-element-sublabel"><?php _e( 'Venue URL', 'eventorganiserfes' );?>:</label> <input type="url" value="http://" data-eo-venue="url" class="<?php esc_attr( $this->element->get_class() ); ?>" name="<?php echo $this->element->get_field_name( 'venue_url' ) ?>" value="<?php echo esc_attr( $this->element->get_value( 'venue_url' ) );?>"/>

    I need this as a link on the Venue name in the events list so that when you click on Venue name you land on the Venue’s website.
    . Can you please give me an idea how to do it i’m a bit stuck.
    Many thanks
    Petra

    Petra Mezei
    #17255

    Hi Petra,

    While adding a field to the mark-up will capture data from the user, Event Organiser FES won’t do anything with that data, (as it doesn’t know what it is). You’ll need to store it yourself. The plug-in was designed to take front-end submissions of events, and store additional event data (not venue meta data), so I’m afraid you’ll need to a do a bit of the leg work yourself:

    add_action( 'eventorganiser_fes_submitted_event', 'my_post_event_form_submission_callback', 10, 3 );
    function my_post_event_form_submission_callback( $event_id, $event, $from ){
        //Check event has a venue:
        if ( ! ( $venue_id = eo_get_venue( $event_id ) ) {
             return;
        }
    
        //Get field with venue element:
        $venue_el = $form->get_element( 5 ); //TODO change this ID as appropriate
    
        if ( ! $venue_el ) {
             return;
        } 
    
        $url = $venue_el->get_value( 'venue_url' );
    
        if ( $url ) {
              //Take a note of the meta key used here:
              eo_update_venue_meta( $venue_id, 'venue_url', $url );
        }
    }
    

    This should go in a utility plug-in / theme’s functions.php.

    Please note that I’ve not tested the above, but it should get you started in the right direction. If nothing else, you can get probably get the venue url by inspecting $_POST, and retrieving the venue ID from the event as above. Note that you shouldn’t expect there to always be a venue url in $_POST (e.g. didn’t select a venue or selected a pre-existing one).

    Venue url:

    Venues are taxonomy terms, and their url (by default) is that of the term’s page. If you want to swap this out for an external link you can do so using the term_link filter: https://codex.wordpress.org/Plugin_API/Filter_Reference/term_link (you should check that the $taxonomy is event-venue and then use eo_get_venue_meta() with the term ID and appropriate meta key (as above).

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.