Multisite: setting theme and options when a new blog is created

The best hook I can find is wpmu_new_blog (line 1086, wp-includes/ms-functions.php, wpmu_create_blog()) – it passes 6 arguments like so; do_action( ‘wpmu_new_blog’, $blog_id, $user_id, $domain, $path, $site_id, $meta ); $meta is an array of initial site options, not to be confused with the options generated by populate_options(). Programatically creating nav menus may prove to be a … Read more

Send activation email to user after signup [duplicate]

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 users you can insert certain code into that column with custom sql. After the user is signed up with wp_insert_user() and returns an … Read more

Is it possible to stop a theme activation when a certain plugin is not activated

Using after_switch_theme will activate the theme (which is fine as we want to run the check within the context of the new theme). If the dependencies are not fulfilled ($missing_dependencies = true;) we’re instantly switching back to the theme previously used (passed via after_switch_theme and $oldtheme). add_action( ‘after_switch_theme’, ‘check_theme_dependencies’, 10, 2 ); function check_theme_dependencies( $oldtheme_name, … Read more

Viewing output when the “The plugin generated x characters of unexpected output during activation” error is triggered

Interestingly the ability to display errors and output from a plugin on activation seems to be build in to WordPress. If you take a look at wp-admin/plugins.php there’s a case in the $action switch statement that says error_scrape — hinted at in Lars’ answer. Looks like this: <?php // wp-admin/plugins.php case ‘error_scrape’: if ( ! … Read more

Show a confirm message before plug-in activation

You can read more about the details of activation on this answer. Basically you need to hook a function to register_activation_hook() – assuming, that this is from within your main plugin folder and not a subfolder: register_activation_hook( __FILE__, ‘on_activation’ ); function wpse65190_on_activation() { // Add an admin notice: add_action( ‘admin_notices’, ‘wpse65190_on_activation_note’ ); // Then you … Read more

__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 hook was hooked from plugins_loaded it was never run on activation. And since it’s never fired ever again, this way of hooking results in register_activation_hook … Read more

File not found.