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;
Related Posts:
- In what part of the WordPress core does the users table and usermeta table get joined?
- Extend the wp_users table
- Select Multiple meta_value from WP DB; Single Query
- Getting all the users who have author privilege
- How to Access wp_usermeta Data Immediately After a New User is Created
- Best practice to import user base (subscribers) from one website to another?
- Users table missing from Database [closed]
- How to delete a particular row in a database table
- Recovering the table wp_usermeta from users
- Storing user submitted forms [closed]
- wp_insert_user not creating account correctly when ID is manually set
- Select From wpdb – Author/User Directory page
- how add more field to wp user and save it to database
- Move Non-WordPress users table to WordPress database
- How to get the id of recently registered user from database?
- How to get specific table by current user login
- update multiple user meta field based on another meta field
- Using wpdb to connect to a separate database
- WPDB Insert or if exists Update
- get_results using wpdb
- $wpdb won’t insert NULL into table column
- wpdb->insert multiple record at once
- How to define composite keys with dbDelta()
- Hook into $wpdb
- How does $wpdb handle COUNT(*)
- WordPress database error: [Query was empty] [closed]
- LEFT JOIN, INNER OUTER JOIN, LEFT OUTER JOIN is driving me crazy. Please help?
- Search multiple meta keys at once
- Efficiency on displaying random authors based on large database
- Updating all rows of table with $wpdb
- How to execute mulitple statement SQL queries using $wpdb->query?
- Is $wpdb->prepare escaping to much? How to use it properly?
- When and why should I use $wpdb different return types?
- How wordpress accesses its own database
- Remove database entries where post_date > expiration date
- Error connecting to DB in /wp-includes/wp-db.php on line 1538 [closed]
- Set Display Name to first and last name (phpmyadmin SQL Query)
- How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?
- How to use a different database to list and manage comments in the backend
- Cannot update custom database table row
- wpdb_prepare with multiple or condition
- Show last modified date of database
- $wpdb->insert is not working
- Extracting the post_id via the wp_insert_post action (external db query)
- WordPress database error – Error in SQL syntax – I can’t identify any error?
- Why is it that not all users have a ‘session_tokens’ meta_key record in the usermeta table?
- Using GROUP CONCAT in my-sql query with wp_usermeta table
- wp_get_current_user always returns 0 continued
- Import users from old WP site to new one
- Create table from array with prepare
- Update from 4.5 to 4.6 failing
- $wpdb->insert Giving duplicates
- Convert user passwords to MD5?
- What can I do when an outside party hacks into my weblog and changes my display name?
- Have working sql query… trying to adjust it to use $wpdb
- Does WordPress store the username as a primary key in the database?
- multiple wordpress installation with shared usertable on an different database
- $wpdb->query can’t insert data
- How to fetch records from database WordPress
- AJAX wp-mysql running too slow
- Some weird users in database
- Problem migrating to localhost
- Connecting to a different database
- Get emails from users by custom field SQL
- How to create more than one new wpdb object?
- Update multiple rows in one query
- I cannot find the difference between these wp_capabilities values in wp_usermeta
- Regenerate user_nicename column
- access JSON results from wordpress database with wpdb
- Getting value from database table depending on field value
- wpdb->insert not inserting first variable
- How do I have a user upload a blog post and then retrieve that to display in a card on the site?
- How to escape percentage sign(%) in sql query with $wpdb->prepare?
- How to get image path from id using SQL
- Migrate Users From laravel to wordpress
- User input to database
- generate PDF from member information
- Change user_nickname for author page link
- how restrict user to give star ratings once for a post?
- Help posting values to DB on submit using $wpdb->query
- create a table using user meta custom data
- How to add download link from database on custom page template?
- insert data from a form:: Warning Empty query mysqli::query()
- How can I get $wpdb to show MySQL warnings?
- About wp database hooks (error establishing connection)
- get_user_meta and umeta_id
- Accessing content from third party as native posts in WordPress
- Should I Use only wpdb Class to Write Custom Queries?
- Hash user emails in database?
- Changed meta_key value in structures, now dashboard shows zero users
- using same mysql user with many databases
- Get id from database
- Pulling values from a sepcific row in table
- import (migration) user database to wp-users
- Inserting into data into external DB using WPDB
- What is best for saving lot of extra detail of user?
- Insert Extra fields added in the front end registration form to DB
- $wpdb->insert not working for last select option
- WP Multisite Users Not Linking
- Query a meta key using an array of values where the database value is a string