Basic programming techniques you should have learned before building a plugin:
- You can concatenate checks with && (and) and || (or).
- You can (and should) guard each
CREATE
query with its own check
SQL syntax you should have looked into before writing queries on your own:
On a related note, please make sure that you delete these tables when the plugin is uninstalled/deleted.
PS: No offense intended, but it does look like you copy pasted without knowing what the code does. Please be aware that by doing this in a plugin you risk other people’s installations!
Related Posts:
- How to Add an Index to Plugin Database table
- Query Posts by Custom Field ‘Price’
- How does WordPress handle MySQL row lock errors?
- insert data in database table from plugin with WP3.1
- How to count number of records found in a database table?
- WordPress register_activation_hook table creation not working
- How use %like% in sql statement wordpress
- Accessing GET variable named ‘error’
- Default Plugin Settings Not Writing to Database
- WP_Query ordering numbers as letters
- Building an email signup form. Where should the information be saved in the DB?
- Plugin Options Not Saving to Database in WP 4.5
- How to create custom tables in WordPress using my own plugin?
- Is it possible to create Custom Post plug-in?
- switched from query_posts to WP_query, not working now?
- Help With MySQL to WPDB Query Conversion
- AJAX search posts and pages
- DROP TABLE with uninstall hook not working
- Prevent duplicate records in plugin table
- WordPress Backend HA (Automatic failover)
- how to use in custom single.php template using php?
- How can I change the meta_key for a particular piece of information?
- How to create a custom shortcode based on the layout?
- Redirect to another page using contact form 7? [closed]
- Can I create a table on my DB without creating a plugin?
- 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?
- How to insert and call new data in wordpress website database through a plugin
- WPDB: Update table
- Issue running db create table query from static method
- Separate database for a wordpress plugin
- Best/Correct way to add an option to a category
- What is the WordPress approach to custom data?
- How to create plugin/ page that reads from database
- DB Query not working in Plugin
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- WordPress plugin: efficient way to store large data
- Delete data from custom table when deleting a post
- Integrating Custom Database with WordPress
- How to display results from a data table with an encrypted user id?
- How to make a Product page without ordering and database
- How to Join wp_posts & wp_postmeta table using custom query
- What database state changes happen after a post is manually “updated” with no changes?
- adding dynamic/multiple slug values in ‘option_none_value’
- I want to schedule email (date, time is in database->table) wp_schedule_event() not working
- How to securely controlling data without keeping it in postmeta?
- $wpdb->insert not working inside save_post tag
- Performance considerations – postmeta table versus new table for custom posts with foreign keys?
- Checkbox field that add a subscription product and change prices of other products in checkout and cart page
- How to use information from the database in the front-end?
- Where do the section input fields values are stored in database
- My plugin can’t see my files
- how can i get records from wp_postmeta table using particular meta_key in database?
- How to insert variable which contain array value in wp_options table?
- Shortcode in a blog post, footer and related products stop working
- wpdb get_var is not returning any result (verified mysql query returns only one value)
- WP-Snap too slow (caused by WP_Query?)
- WordPress Meta Query: Relation is not working correctly
- Insert data in custom table during new post creation
- Making a Custom Post Type Publish Loop
- Checking url from plugin [duplicate]
- Create New Admin Menu Section – Like how custom post type works, in a way
- Creating fields in the database
- How to submit the custom form data in database in WordPress without plugin?
- get_option returning a different value from what’s saved
- How can I delete the options from DB when the plugin is deleted?
- register_activation_hook not working
- On the same site, how do I send data from a plugin file to a theme file?
- plugin doesn’t retrieve data from database
- Accessing Correct Database to Create REST API Endpoint
- fatal error get_page_permastruct()
- Pass $this to function nested in another public function of the same class
- Way to hook into a sidebar call to replace it with a custom sidebar
- WP Plugin Developers – Accessing my wordpress site [closed]
- How to determine what is generating large amount of database queries?
- why doesn’t this update part of this plugin work? it take me to nothing here page
- Using a custom plugin to capture input data via Ajax and PHP
- Display post lists in 2nd paragraph
- Is there a way to test that readme looks in other language before submitting translation?
- Create tabs in admin options page from custom post type loop
- populating a form field with output from a custom plugin function
- Is there a way to add custom endpoint to specific page only
- IF condition based on wp_remote_get output
- Add User Role: Pre-saved in User-Meta [SOLVED]
- How WordPress core manage the plugin installation
- Storing The Data Collected by Ninja Forms into Another (custom) Database [closed]
- count the number of views of a post excluding own views
- How to set Google Analytics tracking code on WordPress plugin directory page?
- Load my Inline js footer area
- Remove action added in plugin class from theme
- wc_get_product_terms() throws “Notice: Undefined offset: 0”
- How do I add a textarea (multirow) option to my WordPress plugin?
- Passing ajax variable to more than one wordpress plugin function
- Why isn’t my plugin seeing other classes?
- How to add jquery to my custom post type wp plugin
- Update post meta not working on wp_postmeta
- wp_insert_post_data filter to set category
- is there a way I can add or remove some plugin options?
- What can I do to customize a widget provided with this plugin? from where have I to start?
- How to add a simple design in classic editor plugin creating post page through another Wp plugin