Support

Home Forums Event Espresso Premium Short Code to list Custom Question "Business"

Short Code to list Custom Question "Business"

Posted: June 5, 2017 at 4:30 pm


Springanew

June 5, 2017 at 4:30 pm

Hi everyone, I’ve spent several hours searching on this and tried <script src=”https://gist.github.com/joshfeck/63fe625950c9a71e19be.js”></script> where line 19 I changed the ID to “21” which is the number for the registration question: What is your Business Name? but it does not show up so I’ve done something wrong. ‘Registration.ATT_ID’ => $contact->ID(),
‘Registration.EVT_ID’ => $event->ID(),
‘QST_ID’ => 21

What I need is the Business name of my attendees to show up with Attendee Shortcode so that I don’t get two of the same businesses.

On the above code do I add it to the existing [ESPRESSO_EVENT_ATTENDEES] or replace the whole page? I’m not a coder so I need simple instructions. This is for a nonprofit fundraiser so I don’t have funds to hire someone or I would in a heartbeat! Thanks!


Tony

  • Support Staff

June 6, 2017 at 6:29 am

Hi there,

where line 19 I changed the ID to “21” which is the number for the registration question: What is your Business Name? but it does not show up so I’ve done something wrong.

Do you have multiple registrations on the event? If so, if the last registration made on the event with your contact doens’t have an answer the above won’t work.

On the above code do I add it to the existing [ESPRESSO_EVENT_ATTENDEES] or replace the whole page?

Where are you adding the code currently?

I’ll outline the steps you need to take for this to work:

Download a copy of Josh’s content-espresso_event_attendees.php templates file – http://take.ms/ww3CO

Extract the template file from the zip – http://take.ms/Erm5x

Change the code to use ‘QST_ID’ => 21

Place that edited template file within your themes root directory – http://take.ms/XE1F5
(for the above you need to use FTP or similar to add the file to the server)

Then view your attendee list and it should show the answer on the list.


Springanew

June 6, 2017 at 12:29 pm

Hi Tony, awesome – thanks for the info. I have a major fundraiser Saturday people are still signing up for so I’ll try all this on Sunday 🙂


Springanew

June 6, 2017 at 1:54 pm

OK I decided to give it a try – and of course I’m missing something. I created a child theme, added a php file called content_espresso_event_attendess.php, and added “only” the code found at https://gist.github.com/joshfeck/63fe625950c9a71e19be and “only” changed the “QST ID” to 21. Now I get this as the list of attendees
USANA/Close to My Heart Leslie Baldwin — Springanew Studio
class EES_Espresso_Event_Attendees extends EES_Shortcode { /** * run – initial module setup * * @access public * @param WP $WP * @return void */ public function run( WP $WP ) {} /** * set_hooks – for hooking into EE Core, modules, etc * * @access public * @return void */ public static function set_hooks() { } /** * set_hooks_admin – for hooking into EE Admin Core, modules, etc * * @access public * @return void */ public static function set_hooks_admin() { } /** * @deprecated 4.9.27 * @param array $attributes * @return string * @throws \EE_Error */ public function process_shortcode( $attributes = array() ) { \EE_Error::doing_it_wrong( __METHOD__, __( ‘Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendeesShortcode instead.’, ‘event_espresso’ ), ‘4.9.27’ ); return ”; } } //end EES_Espresso_Event_Attendees

I’ll keep looking at what I did wrong but if you see if faster let me know – thanks!


Springanew

June 6, 2017 at 1:56 pm

Correction – I typed the file name above with an error – it is typed correctly in the files


Springanew

June 6, 2017 at 2:48 pm

I noticed that is DOES add the custom question! But how do we get all the rest of the code not to show up? Thanks 🙂


Tony

  • Support Staff

June 6, 2017 at 3:02 pm

Have you modifed ANY other EE files other than the custom template mentioned above now within your themes root directory?

The additional code is from something other than the template file.

What version of Event Espresso are you using?


Springanew

June 6, 2017 at 3:03 pm

OK don’t know what I did but it’s working now – let me double check . . . oh my! only thing I did differently was download the php code by zip and copy and pasted that. Perhaps it was an updated file? I dunno – I just glad it’s working! 🙂


Springanew

June 6, 2017 at 3:28 pm

Thanks again Tony and yes I had changed the original attendee file which I downloaded and replaced/restored that back to the original, but I do think it was something in the additional code that might have been in the zip file that was different in the file shown. I keep checking to see it working lol – I appreciate those of you who code 🙂


Tony

  • Support Staff

June 6, 2017 at 3:45 pm

I’m glad this is now working for you.

Just as a general note, it is highly recommended that you do not edit any of the core files within the plugin. We have a huge amount of hooks within EE to allow you to change content and we load a lot of our content through templates that can be modified loaded from a child theme and replaced there. Changing core code means that any testing I (or any member of support) do against the current version may not work the same (or at all) with your ‘modified’ code.

I tested all of the above when posting the reply and had no issues, it may only be something really small that stops it working, code is fussy that way 🙂

We also understand that if you see the code you want to change, it is very tempting and easy to just do it, but it will almost always come back to bite you a little later on in some form or another… forgot about that modification you made and updated the plugin? That modification has now been removed and it’s a mad panic to get anything relying on that code to work again. Using the hooks and various method we have available will, for the most part, avoid all that (exceptions being when we move/alter a hook which is rare but can happen).

Anyway, I’m glad it’s working for you 🙂 If you run into any further problems please do let us know.


Springanew

June 16, 2017 at 12:27 pm

Hi Again! I woke up this morning to see the custom code not working 🙁 WordPress has been updated and EventEsp updated once or twice since I installed the custom php file.

I have the php file in the child theme which is active:
File Structure

and here is the first part of the php file with custom question changed to 21
phpcode
Suggestions? Thanks 🙂


Springanew

June 16, 2017 at 12:28 pm

OK those links don’t work let me see how to share them


Springanew

June 16, 2017 at 12:37 pm

https://www.screencast.com/t/PNCXrURYzu
https://www.screencast.com/t/mNHV1VJkTxBY


Springanew

June 16, 2017 at 12:57 pm

Weird, I went to the event pages in wordpress and in edit event I updated each and now the code is working. I wonder if an update breaks the connection?


Josh

  • Support Staff

June 16, 2017 at 1:39 pm

Hi there,

The update in of itself would not break your customization, but one thing to keep in mind about the [ESPRESSO_EVENT_ATTENDEES] shortcode is it does quite a bit of processing so in order to speed up the page load, there’s some caching involved. You may have been seeing an older cached copy earlier. The cache does eventually expire after an hour, and updating the event rebuilds the cache. There’s a way to set a filter to deactivate the caching, and I can get you that info if you want to turn off that caching.

The support post ‘Short Code to list Custom Question "Business"’ 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