Support

Home Forums Event Espresso Premium how do i add ticket name to my shortcode output?

how do i add ticket name to my shortcode output?

Posted: May 11, 2020 at 7:32 am


mgregor

May 11, 2020 at 7:32 am

hi, i’ve modified the espresso template called ‘attendee-list.php’ to include the email of the registered attendees to my list generated by the shortcode. i’d also like to add the ticket name. i tried the following code, but it’s not working. is there a way to do this? i’m using ee3.

<?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: http://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 (http://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="<?php espresso_template_css_class('event_display_boxes','event-display-boxes ui-widget'); ?>">

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

<div class="<?php espresso_template_css_class('event_data_display','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;
    $ticket_name = $ticket_name->ticket_name;
    $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="12" a="'.$id.'"]');
    //$custom_question_2 = '<br />'.do_shortcode('[EE_ANSWER q="13" a="'.$id.'"]');

    ?>
    <li class="<?php espresso_template_css_class('attendee_details','attendee_details'); ?>"> <span class="<?php espresso_template_css_class('espresso_attendee','espresso_attendee'); ?>"><?php echo $gravatar ?><?php echo stripslashes_deep($fname . ' ' . $lname) . ' - ' . $email . ' ' . $ticket_name . ' ; ?> </span>

    <?php
    }
    ?>

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


mgregor

May 11, 2020 at 7:36 am

sorry for the terrible code. can’t seem to find how to edit it.

here it is in pastebin https://pastebin.com/TEvSKFFm


Tony

  • Support Staff

May 11, 2020 at 8:24 am

Hi there,

Replace $ticket_name = $ticket_name->ticket_name;

With $ticket_name = $attendee->price_option;

If you do something like var_dump($attendee) within the foreach loop (not you’ll want to do that on a test event with a single attendee) you’ll see all of the values you have available.


mgregor

May 11, 2020 at 8:40 am

hmm… i changed that line, but am still not doing something right because the page is just WSOD.

https://pastebin.com/dY0syFDX

i don’t understand what you mean about the var_dump? should i put that somewhere else in my code?


Tony

  • Support Staff

May 11, 2020 at 8:49 am

When you get a WSOD your getting a fatal error, in this case likely a syntax error and you’d need to check the error logs to find it.

In your case, the end line 92 is incorrect:

$email . ' ' . $ticket_name . ' ; ?> </span>

The . ' ; is wrong and is trying to concatenate the string with nothing….

Change it to:

$email . ' ' . $ticket_name; ?> </span>

Does it work then?


mgregor

May 11, 2020 at 8:56 am

thank you. i know just enough about php to break things. πŸ™‚

i changed that and am now able to see the page, but the ticket name isn’t in my lists.


mgregor

May 11, 2020 at 8:56 am

This reply has been marked as private.


Tony

  • Support Staff

May 11, 2020 at 9:16 am

On line 94, just after <?php add a space and var_dump($attendee);

That will output a bunch of data for each attended and possible break the layout for now but it’ll show what is missing.


mgregor

May 11, 2020 at 9:31 am

oh! i got it. πŸ™‚ i had two versions open and had made one change in one, and another in the other and things were getting weirdly overwritten. thank you for walking me through this πŸ™‚


Tony

  • Support Staff

May 11, 2020 at 9:41 am

Ahh, ok. I’ve done that before myself πŸ™‚

Side note if I may, the output it currently a little hard to read, I’m guessing you’re already looking to change it but you can do something like this:

<li class="<?php espresso_template_css_class('attendee_details','attendee_details'); ?>"> <span class="<?php espresso_template_css_class('espresso_attendee','espresso_attendee'); ?>"><?php echo $gravatar ?><?php echo stripslashes_deep($fname . ' ' . $lname) . ' - ' . $email . ' (' . $ticket_name . ')'; ?> </span>

Which will wrap the ticket name in ({ticket-name}), that may be a little odd for ticket names with brackets but will likely make it easier to read in the long run.


mgregor

May 11, 2020 at 10:01 am

thank you, that does make it better on the eyes.


Tony

  • Support Staff

May 11, 2020 at 10:12 am

You’re most welcome.

Any further questions just let us know.

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: publish

Updated by  Tony 2 weeks, 1 day ago ago

Topic Tags

Tagged: 

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!