I guess, you can use the following function
public function pre_install() {
global $wpdb;
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
$sql="
CREATE TABLE IF NOT EXISTS `".$wpdb->prefix."prelauncher`
(
id mediumint(9) NOT NULL auto_increment,
username tinytext NOT NULL,
email varchar(255) NOT NULL,
PRIMARY KEY (`main_id`)
);";
dbDelta($sql);
}
and than your activation hook.
register_activation_hook( __FILE__, array('main_class','pre_install'));
I dont think the $pre_db_versions – required for the this table creation.
I hope this will solve your problem.
Related Posts:
- Create custom column in post table in wordpress
- Should I global $wpdb outside of any of my plugin’s functions scope?
- The plugin generated x characters of unexpected output, $wpdb not defined
- DROP TABLE with uninstall hook not working
- Create a table with wordpress plugin boilerplate
- Multiple instance of data in plugin custom database table on plugin activation
- Can I create a table on my DB without creating a plugin?
- Creating a search form and displaying results
- create pages automatically and dynamically in wordPress
- $wpdb->delete not working for me
- I want to schedule email (date, time is in database->table) wp_schedule_event() not working
- Show a table from data submitted by a form from a user
- WordPress : Explain Plugins & Theme string value in database
- Is it necessary to auto delete my WP plugin database tables when users deactivate/delete my plugin?
- Does deleting a Plugin via the WordPress admin ‘completely’ remove the code?
- Creating a CSV with PHP inside the plugin directory
- Plugins in WP_Options but not Active
- after wordpress update to 3.5+ i get many errors in plugin wpdb::prepare()
- How do i edit the plugin files in DataBase via phpMyAdmin?
- WordPress as a data-store?
- How to insert and call new data in wordpress website database through a plugin
- Gathering and logging data from a plugin: how to do it without race conditions?
- How to pass the API key to the client from the database? [closed]
- WPDB: Update table
- Issue running db create table query from static method
- Problem of encoding characters (apostrophes) in my posts publications
- Separate database for a wordpress plugin
- Is there a rule for wordpress plugins developers to not do any database changes upon update?
- How to keep variable `$post` to using in another file
- dbDelta not adding additional columns in plugin database update
- Updating options into the wp database performance
- Making my plugin create a page?
- Ajax save data to database on document ready, no data being saved
- Add some fileds to the wp_posts table
- How to edit a published post?
- Best/Correct way to add an option to a category
- Plugin has added weird data in wp_options, set to autoload
- Always get creating a new table with foreign key
- How to do database for download stats?
- What is the WordPress approach to custom data?
- How to create plugin/ page that reads from database
- How retreive saved data from gravity forms in my template?
- DB Query not working in Plugin
- Assign all Post in Wp to a specific Category
- External wpdb connections in different plugins on single page
- How can ι create my own (custom) WordPress table/list?
- Storing The Data Collected by Ninja Forms into Another (custom) Database [closed]
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- Where do plugin variables live in the db?
- WordPress plugin boilerplate table create
- Table is not created in WAMP
- How to relate 3 wordpress components with each other (Create database relationships)
- WordPress plugin: efficient way to store large data
- How can I store data from custom fields to custom tables?
- Plugin: connect to external database without showing password
- How to access the WordPress DB from a plugin file
- WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version [closed]
- Table appears in Visual mode of editor but not in preview or after publish
- Storing Form data in a different database
- Interface needed to transfer contents in a table on a web page to the Add New Product interface
- Is this plugin safe to run?
- Can’t create tables with my plugin
- Integrating Custom Database with WordPress
- How to display results from a data table with an encrypted user id?
- Need to add/remove group of options and display them as rows
- How to add a custom form to a plugin’s setting page
- update_option creates an option, which empties on a blog reload
- More than one WordPress site using the same database – how to disable plugin for one site?
- add_action for publish_post doesn’t work
- Getting URL GET parameter with Code snippets and storing it in database?
- How to make a Product page without ordering and database
- How to get specific column data conditionally in database in WordPress?
- Same Plugin tables between wordpress installations
- Some error in mysql script ? Can’t working to create table
- How can I display selected content from a seperate database in an Activity style widget?
- Is classical wordpress eidtor a good option for me to include a large table with a large number of images on my webpage?
- What database state changes happen after a post is manually “updated” with no changes?
- Plugins custom table not being created on activation
- Bulk Edit Media Library alt, caption, image names
- Can i stream data to a custom_post_type?
- Cant create table on plugin activation
- How do I add a medium to the WordPress database with my own plugin?
- A dynamic table plugin to get user input
- Optimise wordpress database using SQL after deleting registered images from Media Folder
- Performing CRUD operations on front end in wordpress
- How to implement data residency in my WordPress site
- How to add specific script to WordPress webpage that will working with user input and databases
- How to use WordPress header function and footer function and not load word press database
- How to securely controlling data without keeping it in postmeta?
- $wpdb->insert not working inside save_post tag
- Get Shortcode output to database for static post_content
- add_action(‘the_content’, ‘my_plugin_content’) is null
- Store GravityForm data in phpmyadmin (mysql)
- My wp database has been hacked
- Moving a few select DB tables to a new WP instance
- WordPress database problem wp_posts, primary key
- How to allow URL with filename & extension in wordpress?
- How to update a database entry with a wordpress plugin?
- Programmatically generate new pages for a site based on page template and content elements accessed via DB
- How wordpress handle urls present in db for external wp-content directory