How to access the Wordpress database?

0 favourites
  • 7 posts
From the Asset Store
Basic Plugins for Firebase Authentication, Realtime-Database, Firestore, Cloud Storage
  • I intend to create a game to be published in a WordPress page (inside of an iFrame) and I need to register the history of each user who plays in the same database of the site (WordPress), recording score, length of stay, results (won or lost), among others. Would it be possible? If so, could you explain to me how to do it? Thanks.

    Tagged:

  • Make a custom PHP page that catches the data required and stuffs it in the database.

    (you can either make a plugin, or a simple standalone page)

    You'll need to add some data, either from the session or derrived from the page, containing the username/id, and send this along to the database.

    You can simply add a new table to the existing database and add a userid reference column, and the other ones with gamename, score, etc etc

    Then, either by a self made plugin, or again a stand alone page, access the database information and show it on the page.

    Personally, I'd go with stand alone setups, ... plugins tend to need to get updated, .... often ...

  • lennaert Thank you for the reply. From what I understand, it doesn't seem like a very complicated thing to do. Do you know where I can find an example of how to create the PHP page and after that how to interact with the WordPress database? I need to understand this very well to see if I really have conditions or not to accept this project.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • lennaert Thank you for the reply. From what I understand, it doesn't seem like a very complicated thing to do. Do you know where I can find an example of how to create the PHP page and after that how to interact with the WordPress database? I need to understand this very well to see if I really have conditions or not to accept this project.

    I think a large majority of PHP database examples / tutorias online will set you off in the right direction.

    w3schools.com/php/php_mysql_intro.asp

    This one is extensive and good, the Mysql section on the left shows all the general concepts and methods. The ones of primairy interest for you are: "Mysql Connect", "Mysql Insert data" and "Mysql select data"

    Your approach in Construct 3 is to use the Ajax object, to send some form data to the PHP page, and in a similair method retrieve it.

    Lots of examples on the construct forums to get you started I guess.

  • Thank you lennaert

    I believe I found the right example/tutorial to accomplish it: construct.net/en/tutorials/tracking-users-ajax-php-mysql-1061

  • That one more goes into detail of the phpmyadmin database interface ...

    search results ajax & PHP

    Check these, the top one shows an actual high score tutorial, with that one start midway page 2. As you allready have a database, and can simply add that table to the wordpress database. Some tinkering is required in order to correlate the posted user data and the wordpress user.

  • Thank you!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)