Support

Home Forums Event Espresso Premium Multiple calls to shortcode ESPRESSO_EVENT_ATTENDEES give same result

Multiple calls to shortcode ESPRESSO_EVENT_ATTENDEES give same result

Posted: May 21, 2016 at 8:58 am


Million TopNight

May 21, 2016 at 8:58 am

Hi,

I am using EE4 and I have aboutly the same problem as described here, but no solution was proposed…

The shortcode calls works well when they are added in a wp page content but they don’t when they are called from php code.

How to reproduce problem :

  1. Create at least 2 events and in the second add one attendee
  2. Open file espresso-events-table-template.template.php
  3. Just above line “if (have_posts()), write php code:echo do_shortcode(‘[ESPRESSO_EVENT_ATTENDEES event_id=210]’);
    echo do_shortcode(‘[ESPRESSO_EVENT_ATTENDEES event_id=255]’);` (adapt the ids with yours)</li>
    <li>The output is twice the same, it shows only the attendees of the first call
    </ol>

    Note: I’ve seen in file EES_Espresso_Event_Attendees.shortcode.php in function process_shortcode that var $this->_attributes keeps the same value

    Thank you for helping
    Gabriel


Josh

  • Support Staff

May 23, 2016 at 1:48 pm

Hi Gabriel,

You can do something like this instead, which will avoid the problems where the fallback short code processor kicks in:

function my_attendee_list( $event_id ){
	return do_shortcode( '[ESPRESSO_EVENT_ATTENDEES event_id=' . $event_id . ']' );
}
echo my_attendee_list( 210 );
echo my_attendee_list( 255 );


Million TopNight

May 26, 2016 at 6:44 am

Hi,
Thank you I will try this weekend and I tell you back.
Gabriel


Josh

  • Support Staff

May 26, 2016 at 7:20 am

Have a great weekend!


Million TopNight

May 30, 2016 at 10:11 am

Hi Josh !
I had a great weekend, thank you πŸ™‚
Unfortunately use this function did not solve the problem πŸ™
Best regards
Gabriel


Josh

  • Support Staff

May 31, 2016 at 9:01 am

Hi Gabriel,

The code was meant to be instructional. If it didn’t work for you, it will help to be able to see how you used the code in context. Can you post the code in a github gist or pastebin.net paste bin, then link here so we can take a look?


Million TopNight

June 1, 2016 at 12:18 pm

Hi Josh,
I know it is just an example don’t worry πŸ™‚ (I am C++ dev engineer)
I put simplified code here http://pastebin.com/6CBtfg1z
Basically it is file espresso-events-table-template.template.php a bit changed, but it appears if I execute do_shortcode() in any file

Thank you


Josh

  • Support Staff

June 1, 2016 at 2:21 pm

Option 1 is don’t use do_shortcode() in a template.

Option 2 is if you use do_shortcode() in the template, you put
<!-- [ESPRESSO_EVENT_ATTENDEES] --> in the post content of the page where you’re running your custom template.

Option 3 is you can open a pull request to fix/remove where EE4 merges in any attributes passed via fallback short code processor.


Million TopNight

June 11, 2016 at 4:00 am

Hi Josh !

My apologies for the late answer, I had a lot of work these last days…
I want to say THANK YOU because the solution option 2 did work !

So the solution is to execute the sortcode without any argument before the loop :

<?php
do_shortcode('[ESPRESSO_EVENT_ATTENDEES]'); // <- this is the solution !

while ( have_posts() ) : the_post();
    $event = EEH_Event_View::get_event();
    echo do_shortcode( '[ESPRESSO_EVENT_ATTENDEES event_id=' . $event->ID() . ']' );
endwhile;
?>

Best regards, have a nice day
Gabriel


Lorenzo Orlando Caum

  • Support Staff

June 13, 2016 at 9:52 am

Hi Gabriel,

Thanks for sharing your solution. Were there any other questions that we could help you with?


Lorenzo


Million TopNight

June 19, 2016 at 5:01 am

Hi,

I confirm that the bug is solved since v 4.9.1p πŸ™‚
Thank you Lorenzo, I have another question I will post it

Best regards
Gabriel


Lorenzo Orlando Caum

  • Support Staff

June 20, 2016 at 4:08 am

Thanks for confirming Gabriel! I’ll update your support post to resolved.


Lorenzo

The support post ‘Multiple calls to shortcode ESPRESSO_EVENT_ATTENDEES give same result’ 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