Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pue-sales domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the better-click-to-tweet domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pue-amazon domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pue-stats domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114
Update User Meta | Event Espresso - Staging Server

Support

Home Forums Event Espresso Premium Update User Meta

Update User Meta

Posted: December 19, 2013 at 2:47 pm

Viewing 6 reply threads


Cedar Springs Ski Club

December 19, 2013 at 2:47 pm

Hi, I’ve been trying to do what it was discussed on a topic created by Stian Morsund http://staging.eventespresso.com/topic/add-profile-information-from-registration-page/

Unfortunately, I have not been able to make it work. I have couple issues, first I’m also using the code from https://gist.github.com/sethshoultes/5574217 to create an user and it works but the admin is not receiving the notification email that one normally gets when a new user is created. And second, I’m trying to follow the instructions to update user meta but I’m getting coding error. Please help, thanks!


Anonymous

December 20, 2013 at 8:30 am

Hi Cedar,

If you can post the code, or upload somewhere for us to view we can guide you a little better.

In effect the simplest method is to wrap each field within the update_user_meta() function from the post linked. Like this for example from line 27:

update_user_meta($user_id, 'event_espresso_address’, $attendee_data['address'])
update_user_meta($user_id, 'event_espresso_address2’, $attendee_data['address2'])

Edit – altered code


Cedar Springs Ski Club

December 20, 2013 at 9:27 am

Hi Tony, thanks for your quick reply. This is what I have and is not working.

/**
* Event Esspresso Create User
*/
add_action(‘action_hook_espresso_save_attendee_data’,’espresso_create_wp_user’, 10, 1);
function espresso_create_wp_user($attendee_data) {
if( username_exists( $attendee_data[’email’] ) == NULL ) {
global $org_options;

// Generate the password and create the user
$password = wp_generate_password( 12, true );
$user_id = wp_create_user( $attendee_data[’email’], $password, $attendee_data[’email’] );

// Set the users details
//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’),
)
);

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

//Update User Meta
update_user_meta($user_id, ‘event_espresso_address’, sanitize_text_field( $_POST[‘event_espresso_address’] ));

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

} // end if
}

Please let me know what am I doing wrong, thanks!


Sidney Harrell

  • Support Staff

December 20, 2013 at 12:24 pm

I thought I remembered working on this before. Try this code:


Cedar Springs Ski Club

December 20, 2013 at 2:08 pm

Hi Sidney, thanks a lot that worked, amazing support! One last thing and I’m done with this, normally when one creates a user in wordpress the admin receives an email too. Is there a way to include that in the code? Thanks again!


Seth Shoultes

  • Support Staff

December 21, 2013 at 12:27 am

Hi,

Think WP would send that out automatically. You could probably another wp_mail line that has the site admin info in it.

Hope that helps.


Cedar Springs Ski Club

December 23, 2013 at 7:48 am

Hi Seth, yes normally WP send a notification automatically but it’s not doing it when the user is created using EE forms. I’ll try adding another email line. Thanks!


Anonymous

December 23, 2013 at 10:01 am

You could try using the wp_new_user_notification() function.

http://codex.wordpress.org/Function_Reference/wp_new_user_notification

You would need to modify the code and remove the current wp_mail call otherwise the user will receive two confirmation emails.

Viewing 6 reply threads

The support post ‘Update User Meta’ 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 - Staging Server