Support

Home Forums Pre-Releases Attendee Batch Import Tweak

Attendee Batch Import Tweak

Posted: May 6, 2014 at 2:30 pm

Viewing 4 reply threads


Pixel Workshop

May 6, 2014 at 2:30 pm

Hello!

I have a lot of attendee data to import for over 1000 attendees, that’s already available in a csv file, and rather than use the question id | answer || question id | answer format, I thought it’d be faster to change the script in the espresso_import.php file to add all that data.

//Add event data
if ( $wpdb->insert(
EVENTS_ATTENDEE_TABLE,
array(
‘registration_id’ => $registration_id,
‘fname’ => $fname,
‘lname’ => $lname,
’email’ => $email,
‘quantity’ => $strings[5],
‘event_id’ => $event_id,
‘amount_pd’ => $strings[7],
‘payment_status’ => $strings[8],
‘price_option’ => $strings[9],
‘start_date’ => event_date_display($strings[’10’], ‘Y-m-d’),
‘event_time’ => $strings[11]
),

Would the correct format be:

‘question_id x’ => $strings[x],

where x is the question ID?

Thanks for your help!


Pixel Workshop

May 6, 2014 at 6:00 pm

Or is it cleaner in go into the the MySQL tables and give each question a system name rather than using question numbers? There’s a lot of questions and a lot of attendees, but will only have to do this once for a handful of events for this particular client.

This is a triathlon producer who inherited a few events from another producer that went out of business. So, I have the database dump from the other producer’s system and want to pull it in to ours, which includes new registrations for the same events. Its complex, but critical since we have medical info and emergency contacts and such.

Thanks!


Dean

May 7, 2014 at 2:04 am

Hi,

The questions data does not go in the events_attendee table. Instead it goes in the events_answer table (the Constant is EVENTS_ANSWER_TABLE).

You will also need to make sure that the questions are set up, otherwise you wont see the information in the attendee pages.

If you are happy working with SQL, then that might be the cleaner approach, but as always backup first and do a test run or two on a development server.


Pixel Workshop

May 7, 2014 at 5:45 am

? Good morning!

Thanks, Dean. “Happy” working with SQL? Well, I don’t mind tinkering, and I always like to learn a few things, but this is pushing my comfort level a bit. I sat last night and looked more closely at the tables in the database and the insert method, and looks like I’m working in this section:

<pre class=”brush: php; gutter: true; first-line: 1; highlight: []; html-script: false”> if ( $wpdb->insert(
EVENTS_ANSWER_TABLE,
array(
'registration_id' => $registration_id,
'attendee_id' => $last_attendee_id,
'question_id' => $x_q,
'answer' => $x_answer,
),
array(
'%s',
'%d',
'%d',
'%s'
)
) === false ) {
print $wpdb->print_error();
}
}
break;
}

Although there are a few values that look like they do go in EVENTS_ATTENDEE_TABLE like address, phone, payment_date and txn_id that I do want to pull in from the old data. Mostly thats to cover my client so they have that info if an athlete shows up and said they paid, but didn’t.

I am running in a staging server, but just to verify my syntax before I really dig in, in EVENTS_ANSWER_TABLE it would look like:

‘question_id_X’ => $strings[Z],

where X is the existing Question ID Number and Z in the column in the csv file.

And then here’s a final question, if I’ve installed the script the creates a wp_user for every registrant, will those be created created when I import? Probably not since I think its hook is at save_attendee_data or something like that, but maybe I’ll get lucky.

Thanks!


Dean

May 8, 2014 at 1:38 am

Hi,

The structure is like this: http://take.ms/H8nhW

So you would want to add (this is in array form rather than SQL)

//ignore the column id, it is an auto increment.
registration_id => 1
attendee_id => 1
question_id => 1
answer => ‘sometext’

So each column in the table will need an appropriate answer. In your example you have merged the question id together with the answer, when they should be separate.

PHPMyAdmin or the Adminer plugin can be useful to get an idea of the database structure.

“the script the creates a wp_user for every registrant, will those be created created when I import?”

Nope. The script fires on an action hook which when importing directly into the database (or even via CSV) will not fire, so no user will be created.

Viewing 4 reply threads

The support post ‘Attendee Batch Import Tweak’ 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