I managed to solve after several attempts using the following code:
// Insert the role
$role = array('gold_role' => 1);
$serialized_role = serialize($role);
$DB_MEMBERSHIP->insert('wpvm_usermeta', array('user_id' => $user_id, 'meta_key' => 'wpvm_capabilities', 'meta_value' => $serialized_role));
It works very well and doesn’t slow down the shopping experience.
Related Posts:
- How to auto login user again after change user_login
- How to Join two tables from separate databases within WordPress
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- WPDB: how to get the value of a field in a custom database table
- How to generate page content from database the right way?
- phpMyAdmin displays error when importing database
- Transferring working local PHP site to wordpress – with database (MySQL)
- Databases – Submitting data from inputs to database [closed]
- Is it best to avoid using $wpdb for security issues?
- Lost in trying to create user database system
- Filter results from a serialized string to use on statistics
- wordpress site – using custom database and PHP
- Front end/Database connection in WP
- direct query to post_meta table
- can’t delete a row from post_meta table
- Can not manually create a database ( db, user, pass ) for a plugin
- Querying multiple meta_keys in WordPress SQL query
- Retrieve data from external database and insert back in
- How to return number of found rows from SELECT query
- $wpdb->get_results(…) returns empty array despite correct query
- Inserting dynamic content into a page
- Check if post of title already exists
- How to export/import theme customizer settings?
- $wpdb->delete column values IN ARRAY()?
- How to make WordPress plugin check for database changes and then do something?
- WP API V2 returning Invalid User ID
- How to display multiple Post meta_key/meta_values by SQL query
- Export User Info to CSV from Front End
- WordPress admin never finishes saving page on site with large page count
- Retrieving and Displaying Data From a Table
- error importing localhost export file to server
- How to sort results from a custom database table
- Notice: wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder
- Database “Migration” for Plugins?
- No wp-config.php file on local install of wordpress – site still displays
- Access/update database with jQuery
- Add custom php database code above
- wp_insert_post not working
- database interactions using OOP
- how to delete 30 day old data using PHP [closed]
- Accessing the database from a plugin outside of action hooks
- Create WP_Query to search for posts by their categories or their parent/child categories
- Storing Array from returned database query and using the array in a new query
- WordPress not reflecting changed of the database
- How to save checkbox values for logged in users?
- Querying wpdb using PHP
- Execute long and heavy processes
- Archive post by meta value + 24hours
- Genesis framework comments broken?
- db converts decimal number wrong
- Filtering a Database Query
- Blob file download problem
- wpdb prepare insert table doesn’t work
- Should I use WordPress to skin a database website?
- Creating Database Table vs. Adding MetaData to Post & User
- dynamic page using php from sql database
- Correct PHP to output a single result of a Function with SQL Query
- How can I add a new row in a separate database when someone registers via WordPress?
- Cant connect to database with php 7.3
- Delete database record using plugin from admin panel
- How to get image from url from the database?
- Creating custom page template from existing PHP site
- Use variable in SQL statement
- Why my query does not run with prepare
- phpMyAdmin error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’
- Fetching review value using wpdb class
- WP_Query: How to get results from both meta_key options?
- Database entry removed on browser refresh, Ajax PHP jQuery
- Database SQL query error
- Change wordpress’ database data using ajax – how to get current user id?
- Limiting posts based on nested meta_query
- Trying to create a shortcode to display categories with a specific product tag
- Custom User registration system
- Preserving backslashes in post_content
- How to use Multi SQL Database in WordPress?
- Woocommerce – get daily sales meta
- Retrieving and Displaying Data From a Table
- Using custom php to connect to database blocks wp from accessing galery pictures
- Running a PHP SQL script on a wordpress page
- Can I disable auto increment of WordPress Posts Database to utilize previously deleted records?
- WordPress search query, how to modify the sql
- Updating the database after parsing CSV document
- Inserting other fields to existing registration form in a WordPress theme
- How to display post_content from database in different on template page?
- Issue in url update when using wordpress update query
- special characters not supporting in wordpress
- How to set max users to 17.000
- Sum of Custom Meta written by Authour
- How to fetch results from database
- How to connect database table to each registered wordpress user.
- Create an unique ID number after submit form
- How do I empty a specific meta_value for all users in PHP
- Create custom table for wordpress custom registration flow
- Search results always returns “No results” no matter what
- Custom form that stores data in mysql database
- How to get data (not value or name) from radio options to POST to database
- Creating a table via dbDelta
- wpbd to connect to a VPS mysql database
- How to get the last date updated of postmeta?
- Putting form result in my database