Change WordPress prefix for only one table?

In wp-config.php for your second site, define the following two constants: define(‘CUSTOM_USER_TABLE’, ‘yourfirstprefix_users’); define(‘CUSTOM_USERMETA_TABLE’, ‘yourfirstprefix_usermeta’); You’ll have to add some custom logic to your second site limiting logins by user role.

Modify Database in Multi-Site wp_usermeta table

This Should Work? ALTER TABLE wp_usermeta ADD COLUMN old_user_id bigint(20) unsigned; INSERT INTO wp_usermeta (old_user_id) SELECT u.id FROM wp_users AS u; INSERT INTO wp_usermeta (user_id, meta_key, meta_value) SELECT u.id, ‘wp_2_capabilities’, meta_value JOIN wp_users AS u ON u.user_id = u.old_user_id; ALTER TABLE wp_users DROP COLUMN old_user_id;

Check if column exists for one table in DB

I found this solution : here So… class MainClassAddon{ public function __construct(){ register_activation_hook( __FILE__, array( $this, ‘install’ ) ); } public function install(){ $row = $wpdb->get_results( “SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name=”wp_t” AND column_name=”c”” ); if(empty($row)){ $wpdb->query(“ALTER TABLE wp_t ADD c INT(1) NOT NULL DEFAULT 1”); } } } new MainClassAddon(); register_uninstall_hook( __FILE__, array( ‘PluginNamespace\MainClassAddon’, … Read more

Modify MySQL Query Based on Dropdown Menu

You don’t need to write your own queries, just use wordpress functions. For instance, to get post by id; use get_post <form method=”POST”> <select name=”post_ID”> <option value=”21″>21</option> <option value=”22″>22</option> </select> <input type=”submit” value=”Get Selected Value” /> </form> <?php $post_id = $_POST[‘post_ID’]; if ( is_int( $post_id ) && !empty ($post_id ) ){ $post = get_post( $post_id … Read more