Manually adding registrations from the admin linking to WP user not working

All our customers have to be logged in as a WP user before they can register for an event. Now this works well when they register for an event themselves. But if we add a customer to an event using the admin option “Add New Registrations” the user is not linked to the WP user. I have tried to sync the WP user account to the EE contact using the gist from @joshfeck https://gist.github.com/joshfeck/2165ff295c968f861cef8775fc8b1dc9 but as commented in the gist the method does not work anymore.

The gist method still works for sites with WordPress 4.8 or lower. Since WordPress 4.9 includes breaking changes for the Debug bar console, the code included in that gist would have to be executed via command line or within a plugin. If adding the code to a plugin, the code can be run once on activation via the register_activation() hook.

Ok thx for explaining how to fix this Josh, but to me this should be something that should be unnecessary to do. Instead of having to manually link EE contacts with WP users I would expect activating the WP user plugin should link users automatically also when they are registered by an administrator?

I understand your question, but when an administrator is adding registrations on the back-end, they are logged in with their own administrator account. So the registrations are not connected to their or anyone else’s account.

If you want to add a registration and have it linked to a specific user account, then you’ll need to log in as that user account. Alternatively you could use a plugin like “User Switcher” to temporarily switch to that user account, then register for the event on the front end.

Alternatively you could use a plugin like “User Switcher” to temporarily switch to that user account, then register for the event on the front end

Yes I found out this is the only method that will work, but it’s a real pain to have to do this if you have a lot of registrations to enter. Most of our customers will register for or events themselves, but we do also have quite a few that for many different reasons need help to register. The admin registration option is a lot faster and easier!