• Phillip Dews

    (@phillipdewsblogger)


    Hi All,

    I am developing a social network from the ground up using PHP, MySQLi, HTML5 and CSS3. The code I have used for all of this is all my own custom code and it works really well.

    However I want to add a blog on the site under a folder called mysite.com/blog/ with a seperate database! I had considered coding up my own but feel that WordPress would be much better for this!

    When a person sign’s up to my site they are entered into a databse naturally. My question is this: Can they also get a user account on the WordPress blog when they sign up on my site automatically?

    Many thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Sure you can:

    1) When you process new users on site A (non-wordpress site), you’ll want to perform an additional step of creating a new user programatically on site B (wordpress site).

    2) You will prob have to use random info for the username and password; unless you incorporate another interface where they can “choose” this info. (Remember to MD5 the user password).

    3) Now, connect to site B and SQL insert the user.

    Thread Starter Phillip Dews

    (@phillipdewsblogger)

    Hmm Seems simple enough then!

    Any code examples out there that I could cannibalize, at all?
    Cheers Josh.

    – Phillip

    Lol… love your personality ??

    Google “add users to WordPress programmatically”.

    Just be careful. Since you are working on adding the user from a non-WP website… the typical WP hooks and filters will not be available. Most of the tuts are going to suggest using WP functions to add the user. However, you’re going to want to do it manually… since your site A is not a WP site (and this is where we need to add the code).

    Here is an example IF we were adding the user from a WP site. But that’s not the case; just here for illustration. (actually, it might work if you change those “includes” to the path to your site B).

    I don’t see an example for your specific use-case. But quickly, here is how I would approach:
    1) Create random username and password.
    2) Check DB of site B to see if username already exists. If no, continue… if yes, re-generate another random username and check DB again.
    3) Populate DB with username and password. (email would be helpful also)
    4) Send message to new user??

    Again, it’s a lot easier if you are doing this from a site that is already running WP (because you can use the existing hooks and filters). However, it’s certainly possible to do it manually. You’re just using your own code instead of existing WP code.

    Thread Starter Phillip Dews

    (@phillipdewsblogger)

    That makes a lot more sense now.
    My non WP site does include both email and username and I am using the password_hash function before inserting into my db.

    Once I have got it all figured out I may just publish a blog post on how I achieved it as I am sure there are a few out there that would like to know how to do this!

    Fancy having a look at the site at all?
    – PD

    Certainly.

    And if you do post the code; lemme take a look. You can use pastebin to “hold” the code; and then paste the link back here. Just remember to redact any sensitive info ??

    Thread Starter Phillip Dews

    (@phillipdewsblogger)

    Actually I may make it available on Github dude!
    Here is TBN.Buzz

    It’s still very rough around the edges as I really need to get the backend right first though then can concentrate on making it all look pretty with css!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Create User Account from Non-WordPress Site’ is closed to new replies.