Skip to main content
19 votes

Activate a plugin through PHPMyAdmin or FTP?

//Using this code you can activate your plugin from the functions.php function activate_plugin_via_php() { $active_plugins = get_option( 'active_plugins' ); array_push($...
Anil Jadhav's user avatar
7 votes
Accepted

Send activation email to user after signup

For activation process you can follow following steps: As you can see user_activation_key column in wp_users table. You can make use of that column for sending user activation link. While signing up ...
Alok Shrestha's user avatar
6 votes

Activate a plugin through PHPMyAdmin or FTP?

Just another answer for a different approach that could benefit someone else in the future. You could also move the plugin folder to the Must Use folder (which you will probably need to create if not ...
TomC's user avatar
  • 1,291
5 votes
Accepted

Prevent network activation of plugin

The answers here are overthought and too complex. Why deactivating the plugin instead of preventing activation? Something as simple as calling die('your error message here) upon activation will do the ...
Maciej Kravchyk's user avatar
5 votes
Accepted

__NAMESPACE__ with register_activation_hook

The reason that the plugin activation hook wasn't working in the code provided in the question is that on plugin activation the plugins_loaded hook is never run. Since the register_activation_hook ...
Nathan Johnson's user avatar
5 votes

How To Activate Plugins via Code?

Wordpress provides a function for activating plugins, according to WP Codex function plugin_activation( $plugin ) { if( ! function_exists('activate_plugin') ) { require_once ABSPATH . ...
Mowshon's user avatar
  • 151
5 votes

How to create a page when a theme is activated?

There is a hook specifically for this purpose, called after_switch_theme. You can hook into it and create your personal page after theme activation. Have a look at this: add_action( '...
Johansson's user avatar
  • 15.3k
5 votes
Accepted

Settings not set after calling register_setting()

register_setting does not insert anything in the database. It's supposed to be run in admin_init, not just on activation, and is for building options pages with the Settings API and handles things ...
Jacob Peattie's user avatar
4 votes
Accepted

Detect when any plugin is activated or deactivated

There are few solutions. You can use activate_plugin and deactivate_plugin hooks for example. But... As far as I understand you right, you want to get notified whenever list of plugins get changed ...
Krzysiek Dróżdż's user avatar
4 votes

Must activation/deactivation functions in a class be static?

Depends the way you want to implement it. The static is used because you don't have to instantiate the class to use the functions of the class. It's up to you. I generally would do: <?php /*it's ...
Lucas Vendramini's user avatar
4 votes
Accepted

Unable to activate wordpress importer after installing it

That error suggests that the WXR_Parser class is already "running" or declared. It's possible that a theme or another plugin has incorporated that class and did not check if it existed already before ...
Jami Gibbs's user avatar
4 votes
Accepted

Plugin activation error due to unexpected output

Plugins are loaded before headers are sent. The reason is that you should be able to send your own headers per plugin. And that's why a main plugin file must not create direct output. Wrap your echo ...
fuxia's user avatar
  • 107k
3 votes
Accepted

Login email after registration never sent or received

In my case it was that my web hosting company was blocking my emails. Let me explain. When I created my WordPress install I used my personal email to create the main user account. That email is a ...
1.21 gigawatts's user avatar
3 votes

How to automate wordpress plugin activate and deactivate by php logic?

Method 1 You can use activate_plugin() and deactivate_plugins() to activate/deactivate plugins programmatically. If you want to control the time at which those actions happen, then you can use ...
RRikesh's user avatar
  • 5,635
3 votes
Accepted

Multisite: Activate plugin for subsites only?

In fact, most of plugins work exactly the way you want: You MUST upload them (i.e. install them) on network admin panel, but you can leave them deactivated. Then, you go to an individual subsite ...
Celso Bessa's user avatar
  • 1,118
3 votes
Accepted

Function to activate WordPress theme inside a plugin

Of course there’s a function for that (Codex): switch_theme( $stylesheet ) It: Switches current theme to new template and stylesheet names. Accepts one argument: $stylesheet of the theme. ($...
Krzysiek Dróżdż's user avatar
3 votes
Accepted

Wordpress register_activation_hook table creation not working

The SQL for creating tables in dbDelta() has very specific requirements. From the codex: You must put each field on its own line in your SQL statement. You must have two spaces between the ...
Jacob Peattie's user avatar
3 votes
Accepted

When a plugin gets updated from the repo, does the "activation" hook fire again?

The activation hook is only fired when the plugin is first activated, not when it's updated.
Jacob Peattie's user avatar
3 votes

wordpress in nginx docker container connected to php:8-fpm container and mariadb container isn't creating any tables on plugin activation

Not sure if it is related, but just in case, as for the last time I looked at it WP core 5.8 have bugs in dbdelta relating to MySQL 8 when integers are involved. Latest MariaDb seems to do better. I ...
Mark Kaplun's user avatar
  • 23.4k
2 votes

register_activation_hook in oop approach

Also in a a more OOP approach, you could do it in the following way: In your plugin class : class MyPlugin { private $file_base; /* * Useful in case you put a lot of stuff in this ...
Iván Carrasco's user avatar
2 votes
Accepted

why creating tables using $wpdb is not being executed while installing plugins?

Try using a different method. WordPress fires a hook during plugin activation activate_yourplugin/filename.php. You can use this to create tables. function creating_order_tables() { if(!...
tormorten's user avatar
  • 166
2 votes

why creating tables using $wpdb is not being executed while installing plugins?

Try this one, Also remember int can have maximum of int(11) <?php global $wpdb; // Set table name $table = $wpdb->prefix . 'exone'; $charset_collate = $wpdb->get_charset_collate(); // ...
Kamaro's user avatar
  • 131
2 votes

How can I manually activate a new site in a wordpress multisite network?

The plugin mentioned by swissspidy does exactly what you want, but it has not been updated for a year, and is not tested with the latest WordPress version. This is why I will also add 2 other ...
Nikolay's user avatar
  • 504
2 votes

How can I manually activate a new site in a wordpress multisite network?

WordPress itself has no UI for viewing and managing unactivated users. You might be interested in the WordPress plugin called Unconfirmed that changes this. It adds a new page in the admin that shows ...
swissspidy's user avatar
  • 3,844
2 votes

How to create a page when a theme is activated?

The wp_insert_post() function is where to start https://developer.wordpress.org/reference/functions/wp_insert_post/ . You would place your code to create the post in the theme activation code. The ...
Rick Hellewell's user avatar
2 votes
Accepted

Correct way to use register_activation_hook

This quotation from The Codex clearly states what does this function do: The register_activation_hook function registers a plugin function to be run when the plugin is activated. This means, ...
Johansson's user avatar
  • 15.3k
2 votes
Accepted

Plugin won't activate - cannot declare class (already in use)

Because WordPress already have class named Request https://developer.wordpress.org/reference/classes/requests/ When creating a plugin or using boilerplate to generate, you should add prefix for your ...
Hồ Trọng Linh Ân's user avatar
2 votes

How to properly setup an activation hook

You first example looks corrent. There is however a typo, hence class 'MyPluginAdmin' not found. You include myplugin-admin.php, but then your question seems to suggest the page holding the class is ...
Matt's user avatar
  • 88
2 votes

How to create multiple database tables on plugin activation?

One way to get it to work would be to do it like this: global $wpdb; $wpdb->hide_errors(); // Require upgrade // Set charset $collate = ''; if ( $wpdb->has_cap( 'collation' ) ) { $collate = ...
Faham Shaikh's user avatar
2 votes
Accepted

How to create multiple database tables on plugin activation?

Why only the second? Because dbDelta() supports CREATE TABLE table_name format only. I.e. Exactly "CREATE TABLE" followed by (one space and) the table name. More specifically, dbDelta() uses this ...
Sally CJ's user avatar
  • 39.3k

Only top scored, non community-wiki answers of a minimum length are eligible