How to use is_multisite() in a must-use-plugin?

MU-Plugins load very early– earlier that your theme or your normal plugins. Because of that, you sometimes need to hook functions that you would otherwise not have to hook. add_action( ‘plugins_loaded’, function () { if (( is_multisite() && !current_user_can(‘manage_network’) ) || ( !is_multisite() && !current_user_can(‘create_users’))) { add_action( ‘init’, create_function( ‘$a’, “remove_action( ‘init’, ‘wp_version_check’ );” ), … Read more

Hello dolly type plugin that allows people to add their own

Don’t use settings api for this. Register a custom post type, ‘Joke’ see register_post_type docs add_action( ‘init’, function () { $labels = array( ‘name’ => ‘Jokes’, ‘singular_name’ => ‘Joke’, ‘add_new’ => ‘Add New’, ‘add_new_item’ => ‘Add New Joke’, ‘new_item’ => ‘New Joke’, ‘edit_item’ => ‘Edit Joke’, ‘view_item’ => ‘View Joke’, ‘all_items’ => ‘All Jokea’, ‘search_items’ … Read more

update_meta_user difference in i:1 and b:1, how to write b:1

Your first serialized string is broken. I can’t spot why but you should not be trying to manipulate capabilities manually. You already have a user object. Use it. if( $new_roles === ‘administrator’ ) { $capabilities = array (“administrator”,’activate_plugins’,’delete_others_pages’,’delete_others_posts’,’delete_pages’,’delete_plugins’,’delete_posts’,’delete_private_pages’,’delete_private_posts’,’delete_published_pages’,’delete_published_posts’,’edit_dashboard’,’edit_files’,’edit_others_pages’,’edit_others_posts’,’edit_pages’,’edit_posts’,’edit_private_pages’,’edit_private_posts’,’edit_published_pages’,’edit_published_posts’,’edit_theme_options’,’export’,’import’,’list_users’,’manage_categories’,’manage_links’,’manage_options’,’moderate_comments’,’promote_users’,’publish_pages’,’publish_posts’,’read_private_pages’,’read_private_posts’,’read’,’remove_users’,’switch_themes’,’upload_files’,’create_product’); $user->set_role(‘administrator’); foreach ($capabilities as $cap) { $user->add_cap($cap); } } Untested but that should work. However, you should … Read more