Hiya,
To do this and have them appear on the form what you’d really need to do is to use the event attributes feature of EM and then use a custom hook to have that data pass into the fields you add using Advanced Custom Fields.
Cheers,
Phil
Thanks Phil
Hmmm, was hoping I could use the custom fields I’d created really. Especially as the documentation implies they are one in the same, it seems odd/daft you can’t then get them to output on the submission form.
How would you do the custom hook?
Cheers
You could also use a custom template and use get_post_meta to pull out the data. That might be easier.
Here’s info on get_post_meta:
http://codex.wordpress.org/Function_Reference/get_post_meta
And here’s how to use custom templates:
http://wp-events-plugin.com/documentation/using-template-files/
Thanks but I still don’t see how I can use it for people to submit data into the custom field – as those functions only return a value not allow for a value to be entered- or am I missing something? 🙁
you need to manually edit template file at /wp-content/plugins/events-manager/templates/forms/event/attributes-public.php to include functions like this
to use template: http://wp-events-plugin.com/documentation/using-template-files/
I think to be honest it’s going to be easier to use the #_ATT{} attributes within rather than using my own custom ones.
So how do I do a conditional on an #_ATT{} field?
Thanks,
I output my code like this though:
<?php echo '<strong>Age</strong>: '. $EM_Event->output('#_ATT{Age}') .'<br />'; ?>
Equally, having to add a function for each att seems a tad long winded. Is there no way to do a simple if else statement?
Your help is much appreciated though
if you create similar snippet above you can try something like
echo $EM_Event->output(' {has_age} <strong>Age</strong>: #_ATT{Age} {/has_age} ')
Thanks again,
I’ve tried the below but only Age is displayed. So in my functions file:
function my_em_has_attribute_event_output_condition($replacement, $condition, $match, $EM_Event){
if( is_object($EM_Event) && preg_match('/^has_Age$/',$condition, $matches) ){
if( !in_array($args['Age'],$EM_Event->event_attributes) && !empty($EM_Event->event_attributes['Age']) ){
$replacement = preg_replace("/\{\/?$condition\}/", '', $match);
}else{
$replacement = '';
}
}
return $replacement;
if( is_object($EM_Event) && preg_match('/^has_Cost$/',$condition, $matches) ){
if( !in_array($args['Cost'],$EM_Event->event_attributes) && !empty($EM_Event->event_attributes['Cost']) ){
$replacement = preg_replace("/\{\/?$condition\}/", '', $match);
}else{
$replacement = '';
}
}
return $replacement;
}
add_action('em_event_output_condition', 'my_em_has_attribute_event_output_condition', 1, 4);
Then in my template file:
<?php
global $post;
$EM_Event = em_get_event($post->ID, 'post_id');
echo $EM_Event->output(' {has_Age} <strong>Age</strong>: #_ATT{Age} {/has_Age} ')
echo $EM_Event->output(' {has_Cost} <strong>Age</strong>: #_ATT{Cost} {/has_Cost} ')
?>
Am I doing something wrong?
instead of combining the two custom conditionals try to separate theme.
Thanks, yes thats sorted it! Thank you so much for all your help, it was very much appreciated!