Best way to add to xf_user

LPH

Well-known member
Does anyone have any links or suggestions on the best way to add to the xf_user database?

1. determine db name
2. determine prefix
3. add field

So, the plugin does this to a WP database:

PHP:
$wpdb->query("ALTER TABLE $wpdb->posts ADD `thread_id` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `ID` ");

Is it best practice to do similar to XF or ... ?
 
I would use XenForo's DataWriters to do anything with the XF database. That way the proper events are called to make sure everything is in sync.
 
Thank you. Since I'm very new to this, basically a function would start off like the following ...

PHP:
/**
* A function to create a table in the XF database
*
* @since Version 1.1.5
* @version 0.0.1
* @[USER=13327]Author[/USER] LPH
*/

public static function xf_add_wp_custom_profiles() {

  $db = XenForo_Application::get('db');
  $db->query(self::$table['createQuery']);
}

Next would be writing the query to add fields to the table using DataWriters - which I do not know how to do but am willing to learn ;)
 
Oops sorry, I just looked at what your code was doing. (Still early in the morning here, haven't had any coffee yet).

You are right, just alter the table directly with an SQL query. No datawriters needed unless you're writing to the database.
 
Oops sorry, I just looked at what your code was doing. (Still early in the morning here, haven't had any coffee yet).

You are right, just alter the table directly with an SQL query. No datawriters needed unless you're writing to the database.

Overall, the add-on would allow a person to add, edit, and delete to their profile tab (or a new tab) new fields pulled from their WordPress profile page (if exists).
 
Top Bottom