[themify_is_logged_in]
[php]
####################### my private stuff ############################
function selected_one_venue( $form_id, $post_id, $form_settings ) {
$value = ”;
if ( $post_id ) {
$ptb_event_venue = get_post_meta( $post_id, ‚ptb_event_venue‘, true );
}
?>
<li class="wpuf-el field-size-large" data-label="Event Venue">
<div class="wpuf-label">
<label>Event Venue <span class="required">*</span></label>
</div>
<div class="wpuf-fields">
<select id="ptb_event_venue" name="ptb_event_venue" data-required="yes" data-type="select">
<option value="-1">Event Venue auswählen</option>
<?php // WP_Query arguments $args = array( ‚post_type‘ => array( ‚venue‘ ),
‚post_status‘ => array( ‚published‘ ),
‚order‘ => ‚ASC‘,
‚orderby‘ => ‚title‘,
);
// The Query
$i_query = new WP_Query( $args );
if ( $i_query->have_posts() ) {
while ( $i_query->have_posts() ) {
$i_query->the_post();
?>
<option value="<?php echo get_the_ID(); ?>" <?php if( get_the_ID() == $ptb_event_venue )echo ‚ selected="selected"‘; ?>><?php echo get_the_title(); ?> / <?php echo get_post_meta( get_the_ID(), ‚ptb_venue_postcode‘, true ); ?> – <?php echo get_post_meta( get_the_ID(), ‚ptb_venue_city‘, true ); ?></option><?php } wp_reset_postdata(); ?>
</select>
</div>
</li>
<?php
}
}
add_action( ’show_all_venues‘, ’selected_one_venue‘, 10, 3 );
function update_the_venue( $post_id ) {
if ( isset( $_POST[‚ptb_event_venue‘] ) ) {
update_post_meta( $post_id, ‚ptb_event_venue‘, $_POST[‚ptb_event_venue‘] );
}
}
add_action( ‚wpuf_add_post_after_insert‘, ‚update_the_venue‘, 10, 1 );
add_action( ‚wpuf_edit_post_after_update‘, ‚update_the_venue‘, 10, 1 );
[/php]
[/themify_is_logged_in]