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
- WP_Query does not return the result even if the data is present in the database
- can not serialize and insert data from custom form
- How do I turn a custom post type into a plugin?
- Plugin exceeds memory limit
- How to write one comment and publish on every post using database or plugin?
- How can I implement a notification system in wordpress?
- Redirect to a welcome page after updating plugin
- medoo framework in WP plugin
- Find the URL of the current plugin directory
- WordPress logo upload option in theme panel
- How to automate wordpress plugin activate and deactivate by php logic?
- Custom plugins/Manipulated plugins: Always a terrible idea to inherit these types of WP sites that discourage updates? [closed]
- Where does WordPress register default scripts like jQuery?
- Minimum PHP Required for WordPress
- Adding content before the loop in category pages
- How to get variables from fucntion.php to my plugin files
- admin_notices hook show message all admin pages after plugin activate
- Adding Attachment Display Settings in custom media frame
- Set user ID at time of wp_create_user
- How to include code into functions.php file via a plugin
- building plugin and it is displaying above plugins page
- like to keep reading plugin
- Check if email address exists front end with AJAX in a plugin
- Is the wordpress user-model changed in wpmu?
- Avoiding Duplicate function names in Post Loop (WP_Footer script)
- Creating Tables on Network Activation
- add action for displaying posts using a shortcode
- How do I write into a file (css)
- Make id column as AUTO INCREMENT on plugin activation
- WP Plugin Developers – Accessing my wordpress site [closed]