dalenguyen / firebase-wordpress-plugin

A plugin that helps to integrate Firebase to WordPress
https://firebase-wordpress-docs.readthedocs.io
GNU General Public License v2.0
111 stars 31 forks source link

Sync WP User Registration and Firebase Registration #26

Closed mikro1st closed 4 years ago

mikro1st commented 4 years ago

I build a mobile app including the function of Firebase's Cloud Notification Service. When a user signs up on my App, a new User will be created in my Firebase Project. Everything works perfectly fine. However, when I decided to extend my Service by building an WordPress Website, I got a lot of trouble with including the Firebase Registration Part to Wordpress. At the moment I'm using the standard Wordpress Login Page (wp-login.php) and just redesigned the style using a free version of loginpress. The Wordpress Site allows everyone to register and with the registration I need to create an Firebase Account in sync with the Wordpress account. (Actually I also need the password which is stored in Firebase to be the same as it is on Wordpress, because, when the user decides to switch to the App instead of the Website or vice versa, he needs to be abled to login without creating an other account.

Describe the solution you'd like At the moment you are using seperate Shortcodes for the Firebase Authentication. Which would mean, that I have to manipulate the Login Page of Wordpress. As far as i understood, you need those Shortcodes to later crap the data using jQuery. The Solution i'd prefer contains two steps:

  1. Add the option to use the regular Login Page of Wordpress using the fields inputs "user_pass" "user_login" of form "loginform" instead of your own shortcodes
  2. Adding the function "firebase.auth().createUserWithEmailAndPassword(email, password)" on the Wordpress hook "password_reset". Further this would mean, you also would need to change the password if the user already exists (for example by calling Firebase Auth API (https://identitytoolkit.googleapis.com/v1/accounts:update?key=[API_KEY]) in the Exception Case, when firebase says that the user account already exists.

Describe alternatives you've considered I would love to see a Tutorial how to implement your Shortcodes into the regular Wordpress Login php, without manipulating the original files. Because, when I Update my project i don't want to lose the functionality.

Which fields does it relate to? Firebase Auth

dalenguyen commented 4 years ago

Thanks @mikro1st for suggesting. I have some questions. Does the user need to register and login to the WordPress site?

If not, you can forbid users from registering to WordPress and create a separate page with the login/register shortcodes. Users can register or login under Firebase Auth without interacting with normal WordPress flow.

dalenguyen commented 4 years ago

This is solved: https://firebase-wordpress-docs.readthedocs.io/en/latest/wordpress-user-integration.html