Posted: October 8, 2014 at 1:22 pm
|
Hey there, In order to have Event Espresso automatically create a user, Lorenzo recommended starting with the following: https://gist.github.com/Apina/5576163 Daft question, but where should the file go in the plugin directory? Will the plugin pick it up automatically or do I need to reference it elsewhere? Cheers, Spencer |
Hi Spencer, That function can go in either your themes functions.php or you can create a site specific pluginand include it using that. Or you could also create a file called custom_functions.php, open a php tag and place that function within there, then place the file at wp-content/uploads/espresso/ |
|
|
Hi, Thanks for getting back. I added the code to functions.php, but received the following error: “Fatal error: Call to undefined function event_espresso_add_user_to_event() in /home/anthropo/public_html/mixnmingle.com/wp-content/themes/twentyfourteen/functions.php on line 647” On line 647 is: event_espresso_add_user_to_event($attendee_data[‘event_id’], $user_id, $attendee_data[‘attendee_id’]); However, it does seem to have created the new user as I immediately received the confirmation email containing the password etc. Any idea why the error has occurred? Cheers, Spencer |
|
Hi, The event_espresso_add_user_to_event is not used in the Gist that Lorenzo linked to, is it perhaps from something else you have tried? Without seeing the full code block it’s hard to see exactly why it is there. (If you do paste the full code, please use a service such as pastebin.com). |
|
Hi Dean, My apologies, I sent a link to another bit of code from the same author. Spencer |
|
Ok, the correct bit of code is in place. I have just created a dummy registration, which was created, but the new user is odd. My administrator user account seems to have been overwritten i.e. the admin name has been changed to the false registration name I have just used. Is this because I was logged in already as the admin? |
|
Ok, I have realised that being logged in an trying to register just confuses the system – logged out and registering creates a fresh account as it should. I am now trying to create pages that list the user’s events: [ESPRESSO_MY_EVENTS] in a page when logged in as registered user just displays the short code. [ESPRESSO_EDIT_PROFILE] in a page also only display the short code. Am I missing something obvious? |
|
Hi, The code is set to Update User and to check via email. This will add a new user if the email does not exist or if it exists it will update the user with that email. If you simply want it to add the user then the script will need to be re-written slightly as right now it’s using wp_create_user. Something liek this should work: http://take.ms/i1rPS but it may need tweaking. |
|
Thanks Dean, I used the additional code you linked to and the accounts seem to be getting created ok. However, I seem to be able to log in with the new user details. I tried the regular WordPress login form, but should there now also a login form available within Event Espresso that I can embed in the header so users can log in via there? |
|
Sorry, that should have been ‘I do not seem to be able to log in with the new user details.’ |
|
Hi, Once we have cracked the attendee login, will it then be possible to login with Facebook Connect? |
|
Hi, Would I be wise to install the WP User Integration Add-on? https://eventespresso.com/product/espresso-members/ By the looks of it, it will allow the user to login and view their profile and event information, which is exactly what I need. |
Yes, that integration would be needed for Event Espresso 3: https://eventespresso.com/wiki/wp-user-integration/ — |
|
|
Hi Lorenzo, Thanks I have bought and installed the WP User Integration add-on – this is brilliant. However, I can now see, login, and edit my detail as a member, but still not as a regular attendee. Attendees are not added as user, so how can attendees view their details? Cheers, Spencer |
Hi Spencer, Event Espresso does not manage your users. The WP Members Add-on allows you to set prices based one ‘members’ (logged in users) and ‘non-members’ (non-logged in users) and also provides the ‘My Events’ section which basically links the events a users has registered onto whilst logged in. So in order to log the details the user must log in first. When you say regular attendee, do you mean a user that does not have an account on the site? |
|
|
Hi Tony, Yes, I meant a non-account holder, thanks. I have been adding dummy attendees for testing and receiving a username and password in an email. However, I can’t see where the attendee would use this information. As they are not users, as you said, it is not possible to log in using /wp-login.php…so where do they log in and view their booking? Thanks for your help, Spencer |
Hi, Using the code snippet below in your child theme’s functions.php file or a site specific plugin will create a new user after registration and send them their information: https://gist.github.com/Apina/5576163 The new member will then login through the WordPress admin. You could use a free plugin like Peter’s Login Redirect to send users with a role of ‘subscriber’ to a specific page after logging in so they don’t reach the WordPress admin. — |
|
|
Hi Lorenzo, I implemented that script you suggest with a couple of modifications suggested by Dean: I have the following in functions.php https://app.box.com/s/4jl80odsobn3eiy7fibq The email that comes through does not provide a link for the user to login with, and I can’t see how one would be created from in the wp_update_user array so I could add it to wp_mail at the end of the function. Cheers, Spencer |
Hi, You can add that to the message area. Here is information on wp_mail() http://codex.wordpress.org/Function_Reference/wp_mail Here is how it is used in the sample coding: Here is the line above with some information swapped in: You could add it to the end as shown above. Does that help? — |
|
|
Hi Loreenzo, Thanks for the link – this codex doesn’t give much away on adding HTML and sending the email as HTML. Would you mind pointing me in the right direction? This earlier query seems to be looking for the same solution: https://eventespresso.com/topic/email-headers-adding-plain-text-version-that-is-entirely-html/ Should I take Josh’s last post as a guide? Thanks for your help, Spencer |
|
Sorry, I should have added that we would like to be able to control the default attendee registration email in the same way as all others via the EE plugin. For some reason this one alone is sent as plain text e.g. Hi SpencerYour Username: spen@***.co.uk Your Password: *** |
|
Hi, As per the link http://codex.wordpress.org/Function_Reference/wp_mail The default content type is ‘text/plain’ which does not allow using HTML. You can set the content type of the email either by using the ‘wp_mail_content_type’ filter (see example below), or by including a header like “Content-type: text/html”. Be careful to reset ‘wp_mail_content_type’ back to ‘text/plain’ after you send your message, though, because failing to do so could lead to unexpected problems with e-mails from WP or plugins/themes. There’s an example below, so you filter to set the headers, then after the mail is set you remove the filter: http://codex.wordpress.org/Function_Reference/wp_mail#Examples (third box) |
|
Thanks Dean, How can I replace WordPress as the sender? I have switched on Use Fancy headers, but this does nothing. I suspect this is to do with the email not being generated as HTML in the first place. Sorry if this sounds critical, I’m baffled why this is the only email to not be customisable from with the plugin itself. Cheers, Spencer |
Hi, You can use this plugin: https://wordpress.org/plugins/send-from/ Alternatively, a service like Mandrill or Postmark app will also work. — |
|
|
Hi Gents, I am still very confused about the following: We now have two different user options on the site, which do not seem integrated. A standard registration i.e. not using your WP member integration add on, issues a username and password that seem to have no purpose i.e. they cannot log into anything. If no user is created, what are these details for? If I create a user using WP member integration, then I can log in and view my profile and manage my event bookings. This is fine. I’m puzzled why an account appears to be created (due to the username and password being issued) for a paying customer which they can then not actually gain access to. I have queried this a couple of times and have still not had it clearly explained. Kind regards, Spencer |
Hi Spencer, I think there is something wrong with your setup, because you can’t create a new user account with the WP Member integration plugin. It may help things if you can walk through the code that you’re adding to your site and review how it’s intended to work. I’ll try to outline what happens here: On the 3rd line it checks to see if anyone has already registered with that email. So, if you’re testing and trying the same email address over and over, you will not get a new account. Next block, it generates a password, then it adds the user account (again, as long as a user account doesn’t already exist with the email address they entered on the registration form). Then it sets the role as subscriber. This role is sufficient to log in to the site and view their registrations when the WP Member Integration add-on is installed. Finally, it sends an email to the new user using the wp_mail function. If you desire to change the message and can’t work out the PHP involved, please consider teaming up with a PHP developer. |
|
|
Hi, I have used a third-party plugin to give the user the option to login with Facebook – they can also create a WP user account with this. Perhaps this is not using the WP login functionality in a way that EE can also use? The site is: https://mixandmingleevents.com/ – the login is at the top right. This is the plugin: https://wordpress.org/plugins/zm-ajax-login-register/ If anything rings a bell, I’d be very grateful. Cheers, Spencer |
Hi Spencer, That might be the case. Good find. |
|
|
Is it possible to disable the default confirmation email that is sent by the ‘espresso_create_wp_user’ function? |
|
Hi, I have been told several times that Event Espresso does not use the WP User system or even create a user, so why is the registering person then emailed a username and a password?? I have just attempted to login in via /login.php and the registered details are still not working. I am not talking about the WP User add-on – this seems to be an entirely separate system again – why is this not the only user functionality? I disabled the above mentioned plugin that was allowing Facebook login, so am now only using the default WordPress functionality. The details sent upon registration still do not work, so where do people login? Even more bizarre is that I also cannot disable the email that sends the unusable details. If you can shed some light on any of this, I would be very grateful. I have asked several times, but the answers I am getting do not correspond to what is actually happening i.e. that a username and password is being created that cannot be used. Cheers, Spencer |
|
Just to reiterate, I do understand that a WP user is not created upon registration for an event, so wp-login.php will not work. Why, why, is a registering person sent a username and password that cannot be used? Members can login and view their profile and edit their events, but members are not created upon registration – why are all customers no created as members in the first place? Obviously, this is freaking my client out. Am I missing something incredibly obvious as I simply cannot see how this works? There seems to be two user systems running parallel to one another: one that can access their events and profile and one that cannot even login, even though they had been sent a username a password. Spencer |
|
Hi, I have been using the following code recommended by one of your colleagues: It seems to be sending the newly registered person a username and password that does not enable the user to actually log into the site and view their details. I know I am going around in circles, but I cannot see how this is meant to be work. Kind regards, Spencer |
Hi Spencer, It looks like the modifications made to that code are causing this problem. Switch that code back to the original gist here: https://gist.github.com/Apina/5576163 That code will correctly generate user accounts using the information input into the registration form which can then be used to log into the account as a normal wp user. The code within the Gist checks if the account exists by checking for a ‘username’ that matches the email address entered into the reg form, to prevent your account from being updated when logged in, I would swap this line: if( username_exists( $attendee_data['email'] ) == NULL ) { To: if( email_exists( $attendee_data['email'] ) == NULL ) { Which will check if the email address is registered rather than username (as usernames can/will differ from the email address) |
|
The support post ‘EE3 User Creation’ 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.