How can I get a plugin to hook ‘dbdelta_queries’ — a filter used during version update?

Must-use (mu) plugins are loaded during the version update process, unlike ordinary plugins. Explanation here. So it’s possible to hook dbdelta_queries and the related filters from within a mu plugin. (Thanks to Sergey Biryukov for the answer.) But, some plugins use the same dbDelta() function as core update, so it’s possible to get queries for … Read more

Server database problem

I believe Rarst is right. It sounds like you need to configure the wp-config.php file for the new database. Just go to the cpanel or other control panel of your hosting service, and use the address they use for the host address. If the database is on the same server as the web site, localhost … Read more

How to STOP wordpress trying to update database?

There is a DO_NOT_UPGRADE_GLOBAL_TABLES constant that going by documentation protects tables that are global in multisites (since they can grow large because of that), but I don’t see a clean way to prevent upgrade altogether. I’d work on getting that core clean of hacks instead.

Why WordPress does not Use Separate Table for Post Types (When Registring)?

It would be a challenge to hunt down a specific moment in time when that particular decision had been made. My educated guess would be that storing CPT definitions persistently would complicate how they interact with rest of APIs (especially Rewrite and localization). WP is also relatively conservative with database structure. CPT are relatively young … Read more

Restrict users viewing post using age on database [closed]

There are probably a few ways to do this. The easiest way I can think of is to install Pods Framework. You can install it through the WordPress repository like you’d normally install a plugin, or through GitHub. Using Pods, you can extend the WordPress user database to add a birthday field. You can also … Read more

Problem with form database connectivity

You’re inserting raw POST data straight into an SQL query – sanitize, sanitize, sanitize! The code below should get you started, but I would advise you add some additional checks (is the email valid? are the strings too long? etc.): <?php $errors = $values = array(); if ( isset( $_POST[‘Submit’] ) ) { $fields = … Read more

get_option returning a different value from what’s saved

In the plugin_options_validate() function the return value of get_option( ‘plugin_options’ ) is never used. Let’s step through the function by adding some comments: // Retrieve the options. $options = get_option(‘plugin_options’); // Replace the options without checking if // trim( $input[‘text_string’] ) and trim( $input[‘text_string_name’] ) // actually return strings and if $input[‘text_string’] and // $input[‘text_string_name’] … Read more

Fetch all categories from database

get_categories function will return an array of objects, each object a category. You can read more about it here: https://developer.wordpress.org/reference/functions/get_categories/ Edit And example, as Tim Malone mentioned in the comment there are examples on that page. But here is a simple one for you, that will display your categories in a list. $categories = get_categories(); … Read more