Only allow plugin to be activated on root site of multisite

You could check if the constant SITE_ID_CURRENT_SITE matches get_current_site()->id. The following does this for the activation. During runtime you have to check it again. register_activation_hook( __FILE__, ‘force_main_site_installation’ ); function force_main_site_installation() { if ( defined( ‘SITE_ID_CURRENT_SITE’ ) and SITE_ID_CURRENT_SITE !== get_current_site()->id ) { if ( function_exists(‘deactivate_plugins’) ) { deactivate_plugins( __FILE__ ); } die( ‘Install this plugin … Read more

Problem creating a table with dbDelta

if( $installed_ver != $simple_location_version ) { on first run, $installed_ver is an empty string and $simple_location_version is NULL, so this inequality test will fail and your SQL will never be executed. if you check for strict inequality, it will work: if( $installed_ver !== $simple_location_version ) {

Redirect after User Activation [closed]

Paste this code in your bp-custom.php file or, if you prefer, your active theme’s functions.php file: add_action( ‘bp_core_activated_user’, ‘wpse_70289_activated_user_redirect’ ); function wpse_70289_activated_user_redirect( $user_id ) { $registered_from = get_user_meta( $user_id, ‘registered_from’, true ); wp_redirect( $registered_from ); } I haven’t tested this code myself yet, but it should work just fine. References: http://codex.wordpress.org/Function_Reference/get_user_meta http://codex.wordpress.org/Function_Reference/wp_redirect

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. ($stylesheet is the name of your folder slug. It’s the same value that you’d use for a child theme, something like twentythirteen.) It also accepts an additional function signature … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)