Support

Home Forums Event Espresso Premium Send attendee_id to user meta issue

Send attendee_id to user meta issue

Posted: October 30, 2013 at 4:09 pm


Michael Gyura

October 30, 2013 at 4:09 pm

I’m running into a strange situation when trying to grab attendee data.
I can run the ‘action_hook_espresso_save_attendee_data’ hook and use $attendee_data to grab all of the unique data of attendees, even when multiple people are added.
But, $attendee_data[ ‘attendee_id’ ] prints the same for every user.

[code language=”php”]
Array
(
[registration_id] => 2-527179a16d410
[is_primary] => 1
[attendee_session] => 93fb19d4cf87e14b86a5fcfe14de6106-52716ef900f250.87686713
[lname] => User
[fname] => Primary
[address] => 1596 Moraine Circle, #48
[address2] =>
[city] => Steamboat Springs
[state] => CO
[country_id] =>
[zip] => 80487
[email] => pm@gyura.com
[phone] =>
[payment] =>
[txn_type] =>
[coupon_code] =>
[event_time] => 08:00
[end_time] => 21:00
[start_date] => 2013-11-29
[end_date] => 2013-12-04
[price_option] => Free Ticket
[organization_name] =>
[payment_status] => Incomplete
[payment_date] =>
[event_id] => 2
[quantity] => 1
[amount_pd] => 0.00
[orig_price] => 0.00
[final_price] => 0.00
[attendee_id] => 29
[event_meta] => Array
(
[default_payment_status] =>
[venue_id] => 1
[additional_attendee_reg_info] => 2
[add_attendee_question_groups] => Array
(
[1] => 1
)

[date_submitted] => October 30, 2013
[event_hashtag] =>
[event_format] =>
[event_livestreamed] =>
[] =>
)

)

Array
(
[registration_id] => 2-527179a16d410
[attendee_session] => 93fb19d4cf87e14b86a5fcfe14de6106-52716ef900f250.87686713
[lname] => User
[fname] => Second
[email] => second@gyura.com
[address] =>
[address2] =>
[city] =>
[state] =>
[zip] =>
[phone] =>
[payment] =>
[event_time] => 08:00
[end_time] => 21:00
[start_date] => 2013-11-29
[end_date] => 2013-12-04
[price_option] => Free Ticket
[organization_name] =>
[country_id] =>
[payment_status] => Incomplete
[payment_date] =>
[event_id] => 2
[quantity] => 1
[amount_pd] => 0
[orig_price] => 0.00
[final_price] => 0.00
[attendee_id] => 29
[event_meta] => Array
(
[default_payment_status] =>
[venue_id] => 1
[additional_attendee_reg_info] => 2
[add_attendee_question_groups] => Array
(
[1] => 1
)

[date_submitted] => October 30, 2013
[event_hashtag] =>
[event_format] =>
[event_livestreamed] =>
[] =>
)

)

Array
(
[registration_id] => 2-527179a16d410
[attendee_session] => 93fb19d4cf87e14b86a5fcfe14de6106-52716ef900f250.87686713
[lname] => User
[fname] => Third
[email] => third@gyura.com
[address] =>
[address2] =>
[city] =>
[state] =>
[zip] =>
[phone] =>
[payment] =>
[event_time] => 08:00
[end_time] => 21:00
[start_date] => 2013-11-29
[end_date] => 2013-12-04
[price_option] => Free Ticket
[organization_name] =>
[country_id] =>
[payment_status] => Incomplete
[payment_date] =>
[event_id] => 2
[quantity] => 1
[amount_pd] => 0
[orig_price] => 0.00
[final_price] => 0.00
[attendee_id] => 29
[event_meta] => Array
(
[default_payment_status] =>
[venue_id] => 1
[additional_attendee_reg_info] => 2
[add_attendee_question_groups] => Array
(
[1] => 1
)

[date_submitted] => October 30, 2013
[event_hashtag] =>
[event_format] =>
[event_livestreamed] =>
[] =>
)

)
[/code]

Here is what I am doing. Any idea how I can grab the unique ‘attendee_id’?

[code language=”php”]
add_action( ‘action_hook_espresso_save_attendee_data’, ‘pyd_create_wp_user’, 10, 1 );

function pyd_create_wp_user( $attendee_data ) {
if ( username_exists( $attendee_data[ ’email’ ] ) == NULL ) {
global $org_options;

echo ‘';
print_r( $attendee_data );
echo '’;

$password = wp_generate_password( 12, false );
$user_id = wp_create_user( $attendee_data[ ’email’ ], $password, $attendee_data[ ’email’ ] );

//Additional fields can be found here: http://codex.wordpress.org/Function_Reference/wp_update_user
wp_update_user(
array(
‘ID’ => $user_id,
‘nickname’ => $attendee_data[ ‘fname’ ] . ‘ ‘ . $attendee_data[ ‘lname’ ],
‘display_name’ => $attendee_data[ ‘fname’ ] . ‘ ‘ . $attendee_data[ ‘lname’ ],
‘first_name’ => $attendee_data[ ‘fname’ ],
‘last_name’ => $attendee_data[ ‘lname’ ],
‘description’ => __( ‘Registered via event registration form.’, ‘event_espresso’ ),
)
);

update_user_meta( $user_id, ‘pyd_espresso_user_id’, $attendee_data[ “attendee_id” ] );

// Set the role
$user = new WP_User( $user_id );
$user->set_role( ‘attendee’ );

// Email the user
wp_mail( $attendee_data[ ’email’ ], ‘Welcome to ‘ . $org_options[ ‘organization’ ], ‘Your Username: ‘ . $attendee_data[ ’email’ ] . ‘ Your Password: ‘ . $password );

} // end if
}
[/code]

  • This topic was modified 10 years, 6 months ago by  Michael Gyura.
  • This topic was modified 10 years, 6 months ago by  Michael Gyura.
  • This topic was modified 10 years, 6 months ago by  Michael Gyura.
  • This topic was modified 10 years, 6 months ago by  Michael Gyura.


Dean

October 31, 2013 at 4:14 am

Hi,

That’s actually the correct behaviour, the additional attendees are stored (currently) under the primary attendees registration number.


Michael Gyura

October 31, 2013 at 10:28 am

Thank you for your reply.
In the ‘events_attendee’ table, each attendee has a unique and correctly numbered ID. So, each attendee does have a unique number. It seems that in the Meta Data stored it keeps the number of the primary register. But, in the attendee table they get their unique key. When does that happen and is there a function I can use to grab that unique number at registration?


Dean

November 1, 2013 at 5:08 am

Hi,

It seems we are both correct: with standard registration they share the ID, with MER they do not http://d.pr/i/MDm3

I’m not sure of the exact code, but it would happen at the confirmation display point as that is when they are added to the database.

Looking at it, and bearing in mind I am not a developer, it looks to me like MER is being actioned by the event_espresso_add_attendees_to_db_multi function in event-espresso/includes/functions/add_attendees_to_db.php (this is called from the cart.php file), so I would suggest checking that out.

The support post ‘Send attendee_id to user meta issue’ 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