Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

How can I add a new row in a separate database when someone registers via WordPress?

(As you said, this is not specifically a WordPress question except for how to hook into WordPress functionality with users. Here are some thoughts)

I think there are some design questions you need to have clear in order to make it easy figuring out the order to build things:

  1. Users signing up and signing in to your WordPress website is easy, WordPress does that. But how are you going to facilitate users signing up in an external application? Maybe you need to have a look at https://developer.wordpress.org/rest-api/reference/users/ to make sure you’re clear on how that could happen.

  2. It sounds like WordPress is about to become the authoritative database for your user records. I.e. for the User ID in your game database to be valid, there must be a row in the WordPress users tables. This is something to be aware of because it means your other application’s data will be dependent on WordPress’s database. This is fine and probably not a bad design given that I’m assuming you need WordPress features for your website.

  3. I’d strongly recommend you try and keep the application code for your game separate from WordPress as much as possible. That means put it in separate PHP files as much as possible. The more you mix in WordPress PHP with your application PHP the harder your life will be in building features that are specific to your game. You can achieve this by writing all the code for your game in separate files then making the ‘glue’ that connects WordPress to your game as small as possible. This also means you can build and test a function to e.g. add a user with ID 123 and score 456 to your game database completely separately, then figure out how to add it to WordPress once it’s done.

  4. If you solve item 1, then you could use e.g. the user_register hook (see here) to do stuff when a new user is registered, and the hook will send you the new user ID so you automatically have that in order to make the new row in your other database.

These are just some ideas to start you off, I would recommend that you try to break your question up into smaller pieces if you’re looking for more specific answers.

HTH

Related Posts:

  1. $wpdb->insert() does not Insert record in a table
  2. Use $wpdb or other PHP script method to find/replace in WP database
  3. Database SQL query error
  4. How to return number of found rows from SELECT query
  5. Transaction when using WP functions rather than vanilla SQL?
  6. Can i use php sql functions instead of $wpdb?
  7. $wpdb->get_results(…) returns empty array despite correct query
  8. $wpdb->delete column values IN ARRAY()?
  9. How to get the list of WooCommerce product image of a certain category from database?
  10. Custom query to get post names beginning with a digit
  11. How to make WordPress plugin check for database changes and then do something?
  12. Changing user_nicename
  13. How to Join two tables from separate databases within WordPress
  14. Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
  15. WPDB: how to get the value of a field in a custom database table
  16. WordPress get pagination on wpdb get_results
  17. register_activation_hook isn’t adding table to DB
  18. What SQL / WordPress queries would need a nonce?
  19. Ajax $wpdb not returning table data
  20. Converting MYSQL to WordPress $WPDB
  21. Why is variable not working on custom sql query using wpdb?
  22. Show MySQL errors that occur when I excute $wpdb->insert()
  23. Get stock by custom meta field on all Woocommerce variable products
  24. how to delete 30 day old data using PHP [closed]
  25. Display fields as values in array from external SQL DB
  26. Can’t get wp_insert_post to work
  27. WSoD being caused by this piece of code
  28. I want to select the from values from database in WordPress? [closed]
  29. User management system similar to wordpress one?
  30. Importing Geo data into wordpress database
  31. Querying wpdb using PHP
  32. WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
  33. Update results, Before deleting the related category [closed]
  34. wp query foreach deleting record returning only first or last item
  35. Database query works fine outside WordPress
  36. Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
  37. Help with a $wpdb MySQL Query
  38. Custom array from a query only write the last row of the query
  39. $wpdb returns duplicate posts
  40. Mixing variables into an array when inserting values
  41. Basic wpdb update question
  42. I can’t update my data through $wpdb
  43. Output: “Array”
  44. How to use mysql LIKE with wpdb?
  45. PHP -> SQL Query with Summing
  46. Lost in trying to create user database system
  47. Pull MySQL data from multiple tables and merge into 1 PHP array
  48. How do I prepare strings for insertions as values into a MySQL table?
  49. How to use AJAX in WordPress in MYSQL query?
  50. Use variable in SQL statement
  51. form $_post action value gets truncated after it passes through two forms
  52. Why my query does not run with prepare
  53. Why won’t this wpdb get_results query return results?
  54. WPDB secure custom form
  55. wpdb getting avatars and author url
  56. mySQL queries are executed twice on wordpress website
  57. Add row to custom database Table and delete all rows older than 1 day
  58. select a single val though a table in wordpress
  59. making php value numeric
  60. WordPress SQL JOIN query
  61. populate select options from extra mysql table data
  62. Query the links Database
  63. Fetching review value using wpdb class
  64. MySQL Query Returns Array () In Shortcode
  65. Passing in MySQL prepare statement parameter separately throwing error
  66. Convert a column of a table containing an Array as response in HTML
  67. WordPress SQL Prepare
  68. How to run complex query using PHP
  69. Creating multiple tables with Plugin
  70. MYSQL TIMESTAMP when adding DATE_FORMAT then the output is blank, PHP conflict?
  71. Conditional formatting on data fetched from MYSQL
  72. What is the correct way to search 3 custom fields only in WordPress?
  73. Using wpdb to connect to a different database is not working
  74. Inserting other fields to existing registration form in a WordPress theme
  75. Rewrite SQL query as a prepared statement and use in foreach loop
  76. Advanced WordPress SQL Query
  77. SQL Query Search page
  78. can’t delete a row from post_meta table
  79. MySQL query in WordPress with AJAX
  80. Conditional statement within WP SQL query
  81. Passed variable gets undefined variable error on insert on next page
  82. MySQL queries in WordPress
  83. Using the same shortcode to show any table from the database
  84. Querying multiple meta_keys in WordPress SQL query
  85. MySQL database migration to WordPress
  86. Can’t send form data to wpdb when URL has query string
  87. Error resetting database index using ALTER TABLE in $wpdb->query
  88. Putting form result in my database
  89. How can I update a value of a field depending on outside source?
  90. wpdb prepare insert table doesn’t work
  91. dynamic page using php from sql database
  92. Cannot access $wpdb, comes back NULL
  93. PHP warning – Use of undefined constant ‘FORCE_SSL_LOGIN’ ‘FORCE_SSL_ADMIN’ on wp-config.php
  94. WP + MySql db / PHP
  95. append data to mysql table via submit button coded in php – not working
  96. How to do a MySql query in WordPress?
  97. Newbie question. Login/Registration. New PHP page
  98. How to set max users to 17.000
  99. directorypress theme error mysql_error() [closed]
  100. How to connect wordpress with db using ssl client certificate
Categories PHP Tags login, mysql, php, sql, wpdb
Set site title & tagline with wp.config or function.php
How to check if a post has any one of many shortcodes?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress