Monday, March 26, 2012

I got so frustrated with WordPress that I took the streets of raw PHP/MySQL code to find a solution.

After spending hours finding, installing, implementing, and discarding numerous plugins that I had hoped would fill my need, I went rogue and opened up notepad.

I need a way to password protect a page that viewable only to registered users within a certain role group. Also needed a custom login and registration page. The registration needed to also capture extra fields outside of the standard user fields and register them under a particular role. I tried and tried to find a plugin. I found one plug in to protect a page to only only certain role members to view. I also found a plugin to capture extra user data. I found another plugin to make a custom registration page. But I could not pull it all together.

So after wasting hours of time, I starting writing my own user database, password protecting the page, creating login and registration forms, etc. This also is a time-consuming tasks, but at least I  know it will work and I have 100% control of what the scripts are doing. Editing the PHP code of the plugins was just a mess. It's so hard looking through the plugin code, the WordPress code to find what code and how it needs to be edited.

At this point, I have the database created, the login and registration form created. I have a lot of the functionality there, but there's still a lot of little, but important details to address.

My next step is to create the "reset password" functionality. Right now you can register and login/logout, but there's needs to be a way to reset your password. This requires a function to email the registrant their new password, which would be randomly generated and put into their record. They would also need a way to change their password. I'm thinking these are the last few steps. I have a lot more to do on the site, but at least this challenge is almost done.

I have much more to do. I need to add some Google map API stuff and more registration forms. It's a big project. I'm didn't have a ton of WordPress experience to start out with and now I'm jumping into a pretty advanced site. It's feels good though. I'm streatching my PHP/MySQL skills. It will be good to have this under my belt.

One thing that I had not worked with much was encryption. I needed to encrypt the user's password and then be able to check the entered password at login against the password in the database. That seemed pretty straight forward, but I couldn't get it to work at first. Well, I needed to encrypt the submitted pw to be able to match it to an encrypted pw in the database. It still didn't work. I then realized that the crypt function needed a "salt". Once a put the salt in place it all worked fine. Thanks to this site for learning me on using crypt - http://php.ss23.geek.nz/2011/01/12/Using-crypt.html.

No comments:

Post a Comment