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
CREATEquery 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
- Getting Path To Uploaded Attachment Image After Upload
- Understanding apply_filters
- Editor not displaying dynamically after clicking on the button
- How to submit documentation with plugin
- Placement of Code in Plugin for hooking `save_post`
- How can plugins have their own pages?
- Where does WordPress store plugin (enabled/disabled) status for multisite?
- Reusable functions and tools (Framework)
- Creating a plugin to sanitize comment and the url field before display only
- Creating mySQL procedure with $wpdb
- Editable form for WordPress plugin options page
- wp-pagenavi getting 404 page not found
- remove add new post, if there is already one post
- WordPress checkbox and Illegal string offset
- dbDelta not adding additional columns in plugin database update
- Is it fair to use MIT licensed code in WordPress plugins? [closed]
- How to Show Author image and url in WordPress plugin directory? [closed]
- jQuery code didn’t run on my plugin
- Custom Module, Extending WP with a Plugin?
- How do I profit from a Plugin?
- I created a plugin with ‘view page’ that uses MYSQL + PHP. When I use wp_insert_post(), it turns everything to HTML
- list of custom post by custom field in frontend
- ajax voting for custom post type
- Help me with my first very basic plugin
- Very slow page loads
- How to set meta-data for my plugin
- WordPress isn’t sending welcome email with the password reset
- CPT template is not being automatically used single post pages
- Custom Elementor controls not appearing in the widget Advanced tab using injection hooks