Support

Home Forums Event Espresso Premium attendee details with questions: modifying attendee_list.php breaks site

attendee details with questions: modifying attendee_list.php breaks site

Posted: September 15, 2013 at 10:25 pm


Alice Hohl

September 15, 2013 at 10:25 pm

Hello.
I looked up in the documentation how to copy the attendee_list.php into the templates folder.
I followed these instructions and when I upload the modified attendee_list.php file to the other folder (espresso > templates) it makes my theme break. The site loads a white page. The dashboard loads a white page.
I delete the file, and everything works.
I restore the file, and everything breaks.

I really want to show the attendee name, email address and organization. It shouldn’t be this hard!

I will copy the contents of my php file:

<?php
//List Attendees Template
//Show a list of attendees using a shortcode
//[LISTATTENDEES]
//[LISTATTENDEES limit="30"]
//[LISTATTENDEES show_expired="false"]
//[LISTATTENDEES show_deleted="false"]
//[LISTATTENDEES show_secondary="false"]
//[LISTATTENDEES show_gravatar="true"]
//[LISTATTENDEES paid_only="true"]
//[LISTATTENDEES show_recurrence="false"]
//[LISTATTENDEES event_identifier="your_event_identifier"]
//[LISTATTENDEES category_identifier="your_category_identifier"]

//Please refer to this page for an updated lsit of shortcodes: https://eventespresso.com/forums/?p=592

/*Example CSS for your themes style sheet:

li.attendee_details{
display:block;
margin-bottom:20px;
background: #ECECEC;
border:#CCC 1px solid;
}
.espresso_attendee{
width:400px;
padding:5px;
}
.espresso_attendee img.avatar{
float:left;
padding:5px;
}
.clear{
clear:both;
}
*/

//The following code displays your list of attendees.
//The processing for this function is managed in the shortcodes.php file.
if (!function_exists('event_espresso_show_attendess')) {
function event_espresso_show_attendess($sql,$show_gravatar,$paid_only, $sort=''){
//echo $sql;
global $wpdb,$this_is_a_reg_page;
$events = $wpdb->get_results($sql);
foreach ($events as $event){
$event_id = $event->id;
$event_name = stripslashes_deep($event->event_name);
if (!$this_is_a_reg_page){
$event_desc = do_shortcode(stripslashes_deep($event->event_desc));
}

//This variable is only available using the espresso_event_status function which is loacted in the Custom Files Addon (https://eventespresso.com/download/plugins-and-addons/custom-files-addon/)
$event_status = function_exists('espresso_event_status') ? ' - ' . espresso_event_status($event_id) : '';
//Example usage in the event title:
/*<h2><?php _e('Attendee Listing For: ','event_espresso'); ?><?php echo $event_name . ' - ' . $event_status?> </h2>*/
?>

<div class="event-display-boxes ui-widget">

<h2 class="event_title ui-widget-header ui-corner-top">
<?php _e('Attendee Listing For: ','event_espresso'); ?>
<?php echo $event_name . $event_status?></h2>

<div class="event-data-display ui-widget-content ui-corner-bottom">

<?php //echo wpautop($event_desc); ?>

<?php
$a_sql = "SELECT * FROM " . EVENTS_ATTENDEE_TABLE . " WHERE event_id='" . $event_id . "'";
$a_sql .= $paid_only == 'true'? " AND (payment_status='Completed' OR payment_status='Pending' OR payment_status='Refund') ":'';
$a_sql .= $sort;
//echo $a_sql;
$attendees = $wpdb->get_results($a_sql);
foreach ($attendees as $attendee){
$id = $attendee->id;
$lname = $attendee->lname;
$fname = $attendee->fname;
$city = $attendee->city;
$state = $attendee->state;
$country = $attendee->state;
$email = $attendee->email;
$gravatar = $show_gravatar == 'true'? get_avatar( $email, $size = '100', $default = 'http://www.gravatar.com/avatar/' ) : '';
$city_state = $city != '' || $state != '' ? '<br />' . ($city != '' ? $city :'') . ($state != '' ? ', ' . $state :' ') :'';

//These are example variables to show answers to questions
$custom_question_1 = '<br />'.do_shortcode('[EE_ANSWER q="11" a="'.$id.'"]');
$custom_question_2 = '<br />'.do_shortcode('[EE_ANSWER q="3" a="'.$id.'"]');

?>
<li class="attendee_details"> <span class="espresso_attendee"><?php echo $gravatar ?><?php echo stripslashes_deep($fname . ' ' . $lname) . $city_state . $custom_question_1 != '' ? $custom_question_1 :'') . $custom_question_2 != '' ? $custom_question_2 :'') . '</p>'; ?> </span>
<div class="clear"></div>

<?php
}
?>

</div>
</div>
<?php
}
}
}


Alice Hohl

September 15, 2013 at 10:31 pm

Ah, OK I see where I figured out to remove the open parenthesis provided in the sample code but I didn’t close them.

So I fixed that and now my page is only displaying email addresses, and not names or organizations.
http://kidsandnature.org/blog/?page_id=2379

Please help me figure out the correct php or css to display three pieces of information (first name last name, custom question 1 and custom question 2) on the page in a row.


Tony

  • Support Staff

September 16, 2013 at 1:40 am

Hi Alice,

A couple of alterations.

The shortcode [EE_ANSWER q=”3″ a=”‘.$id.'”] is calling the attendees email. This is required information for all attendees as part of the core and as such can be displayed within attendee_list.php by echoing just $email. (one less database call which is always good)

The code posted includes the gravatar which is fine to leave in but if you want the gravatar to display you need to use [LISTATTENDEES show_gravatar=”true”] if not ignore this comment.

Here is a copy of the code I used to display the information requested. I am unsure of what question 11 is (custom q 1) so have left that as is but this should work for the information you need. It has no styling information currently and is all included within a single p tag so you’ll need to add which ever tags you need.


Alice Hohl

September 16, 2013 at 7:43 am

Very close.
I did that and here’s what I have now:
http://kidsandnature.org/blog/?page_id=2379

The information is there, but also some code is showing.

Here’s what is in my php file:

//These are example variables to show answers to questions
$custom_question_1 = '<br />'.do_shortcode('[EE_ANSWER q="11" a="'.$id.'"]');
$custom_question_2 = '<br />'.do_shortcode('[EE_ANSWER q="3" a="'.$id.'"]');

?>

$custom_question_1 = '<br />'.do_shortcode('[EE_ANSWER q="11" a="'.$id.'"]');
?>
<li class="attendee_details">
<span class="espresso_attendee">
<?php echo $gravatar ?>
<?php echo '<p>' . stripslashes_deep($fname . ' ' . $lname) . $email . $custom_question_1 . '</p>'; ?>
</span>
<div class="clear"></div>

<?php
}
?>

</div>
</div>
<?php
}
}
}


Sidney Harrell

September 16, 2013 at 10:06 am

You should remove the end php tag:

?>

right before the code that is showing:

$custom_question_1 = '<br />'.do_shortcode('[EE_ANSWER q="11" a="'.$id.'"]');


Alice Hohl

September 17, 2013 at 6:26 am

Thank you!
How can I put line breaks in between the items without screwing up the php?
I want it to look like this:

FirstName LastName
Email
CustomQuestion1

Thanks so much for all your help!


Dean

September 17, 2013 at 6:37 am

This should do it

<?php echo '<p>' . stripslashes_deep($fname . ' ' . $lname) . '<br />' . $email . '<br />' .  $custom_question_1 . '</p>'; ?>


Alice Hohl

September 17, 2013 at 6:43 am

Thanks for trying, but that did not do anything:
http://kidsandnature.org/blog/?page_id=2379
They are still smooshed together.


Alice Hohl

September 17, 2013 at 6:50 am

I figured it out. I replaced the
' '
with

'<br />'


Dean

September 17, 2013 at 6:51 am

Odd, though my code was missing the break tags for some reason. Ok, see if separating them into paragraphs works

<?php echo '<p>' . stripslashes_deep($fname . ' ' . $lname) . '</p><p>' . $email . '</p><p>' .  $custom_question_1 . '</p>'; ?>

The support post ‘attendee details with questions: modifying attendee_list.php breaks site’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso