As long as…
- You use
$wpdb->prefix(or$wpdb->base_prefix) to prefix the table - Your table name is someplace public, and easily available for other plugins, themes and end users to use and extend
I would say either setting the table as a property on $wpdb or using a constant is fine. If you choose to use $wpdb be aware that another plugin (or theme or whatever) can just overwrite your property in the same way you set it. For that reason, it’s a bit more “safe” to use something like a constant.
Also, always carefully question whether or not you need to add a table.
I tend to use constants, but if I’m doing something like creating a termmeta table, then I would use a $wpdb property.
Related Posts:
- Should I use wpdb prepare?
- Is it ever okay to include inline CSS in plugins?
- Is it mandatory to use $wpdb->prefix in custom tables
- In Which Contexts are Plugins Responsible for Data Validation/Sanitization?
- Best way to abort plugin in case of insufficient PHP version?
- How can I configure Docker for developing and deploying a custom theme?
- What do you think about custom designed plugin/theme options UIs?
- Is the new WordPress 3.1 admin bar pluggable and how can I extend it?
- Optimize shortcode callbacks
- WordPress and multithreading
- Which to use to execute code during the saving of a plugin settings page?
- Allowing for multiple template views on the Gallery Settings page when using the Visual Editor
- Using Primary Color in Plugin Block
- When is it appropriate to put functions on page template vs. functions.php?
- $wpdb->insert is changing a value
- Actions or filters fired when data is saved in a custom table
- Retrieving custom fields with $wpdb->get_results
- How to create custom home page via plugin?
- Sessions not creating correctly in custom function
- Featured Image not showing in admin
- How to use mysql IN statement with wpdb update method?
- Activation hook not creating table
- Delete a specific item menu when I deactivate my plugin
- Are we allowed to use the Allman (BSD) indent style when coding WordPress plugins and themes?
- Get the password key when using the wp_new_user_notification_email filter
- Order properties should not be accessed directly
- How to Download and install plugin database remotely
- How to deal with equal & similar arguments for a function?
- Executing a function upon webhook calling wordpress
- Customizer: widget-synced triggers twice
- how to use hook deleted_user into custom function to delete user from custom table
- Disable The Events Calendar plugin from loading its scripts
- How to insert data to a database table when the field is not yet created?
- include wp-blog-header not working on MAMP
- WordPress is automatically linking plain text email addresses
- Is Using WordPress Supplied WYSIWYG Advisable?
- ServerSideRender and Media Object: attributes passing image data object to php renderer even though it’s not set
- SQL query for custom taxonomy slugs
- Clearing caches on plugin uninstall
- How to use a hook to override an update_post_meta call in a plugin?
- Issue regarding $wpdb->prepare()
- Error on inserting a form value to database
- how to search users by ajax live search
- How can we display product price $104 on the cart while the credit card payment method is checked?
- Adding custom end points, No error line
- Intermittent database errors when accessing WordPress database
- Storing data in wordpress database from ajax call from different website
- Search: how to extend the existing search to include a custom table
- Is there documentation reference for forms in menu and setting pages?
- How to modify files inside wp-includes directory in wordpress
- How to set a cookie for logged in users to md5($user->ID . “my_secret”)?
- Show message from backend
- Create Widget or Enable Shortcodes in Sidebar
- how to save wp_editor html content in options table
- How to use a WP_Customize_Control outside of the Customizer?
- How to avoid conflicts with db.php / $wpdb and other plugins that decide to use them?
- $wpdb in php 5.5
- How to remove/replace current page template?
- Plugin to create Posts and Forums then choose category and parent forum
- $wpdb->update Issue
- WordPress database error: [Query was empty] – using $wpdb->prepare()
- How to determine which capability to use?
- Custom Endpoint – Does it possible to use PUT method with WP API Rest?
- Why won’t this submenu page show? – My First WordPress Plugin
- How to display specific data from a custom table to logged in users with a custom role
- $wpbd->insert_id is returning null
- How to get inserted row IDs for bulk/batch insert with wpdb query?
- WordPress Query doesn’t return the correct value
- Rate limiting ajax requests in WordPress
- Does hooking into a plugin action / filter override the plugin’s function for that hook?
- Hiding class namespace from plugin’s extensions
- bindParam? WordPress 4.9.5 SQL LIKE statement %s and %LIKE%
- Determine if the current page, is being edited
- WordPress delete mysql rows with string
- external Integration with wordpress timeout error
- PHP includes with AJAX actions
- Making adding info to an overlay bio easy for average user?
- Implementing Select2 plugin into WordPress
- How to implement pagination into a wpdb->result query?
- Custom Post Type and Functions
- Associating special meaning with user id 0
- Can I access WordPress API’s from within plugin scripts?
- Theming Custom Plugin Page
- Best practice: What belongs in theme and what in plugin for large eCommerce website
- Link to a admin submenu item using a custom link
- Adding class to the parent of current-post-ancestor / current-menu-parent / current-post-parent
- Change the search results header from plugin
- Dynamic banner for use on external sites
- WordPress plugin tables become corrupt
- How do I store a custom dataset in WordPress to best take advantage of API?
- Nothing happens on WordPress Update command
- Fixing plugin for wpdb::prepare
- Developing Themes on WordPress, Looking for Excellent Tutorials [closed]
- How to Implement SAM Broadcaster with WordPress? [closed]
- Custom plugin not appearing
- Extend WP_List_Table class – Edit wp_usermeta – WPPB.me Boilerplate – Action error
- Is there any other ways to replicating changes on live from staging without pushing from git
- Can I log the searches that are returning 404 in the DB?
- Custom fields in the billing address section woocommerce
- Add File field in WooCommerce Box office plugin