Add menu page on multisite

I believe you’re looking for the network_admin_menu hook. Here’s how you’d use it: add_action(‘network_admin_menu’, ‘function_name’); function function_name() { add_menu_page( “page_title”, “menu_title”, ‘capability’, ‘menu_slug’, ‘function_callback’ ); }

Allow role to delete posts but block him the wp-admin

Assuming you’re talking about a custom user role named “photographer“, I believe something like this should add the delete_posts capability to that role. function add_delete_cap_to_photog_role() { $role = get_role( ‘photographer’ ); $role->add_cap( ‘delete_posts’ ); } add_action( ‘admin_init’, ‘add_delete_cap_to_photog_role’); After adding the caps to the role, to solve the rest you could either keep blockusers_init and … Read more

Different color admin bars for dev, staging and production

You can use a filter to set the admin color scheme, which includes colors for the admin bar: <?php // add a filter add_filter(‘get_user_option_admin_color’, ‘wpse_313419_conditional_admin_color’); // function wpse_313419_conditional_admin_color($result) { // Dev: use ‘light’ color scheme if(get_site_url() == ‘http://dev.example.com’) { return ‘light’; // Staging: use ‘blue’ color scheme } elseif(get_site_url() == ‘http://staging.example.com’) { return ‘blue’; // … Read more

Only Show an Author Their Custom Post Types

As @s_ha_dum says in his comment, your description and your code seems to be different. If I understand the description, the code to do what you want is: function __set_all_posts_for_author( $query ) { if ( is_admin() && is_post_type_archive( array(‘listings’, ‘contacts’, ‘events’) ) ) { $current_user = wp_get_current_user(); $query->set( ‘author’, $current_user->ID ); } } add_action( ‘pre_get_posts’, … Read more

Adding help information to custom post edit page

Try this: function options_instructions_example() { global $my_admin_page; $screen = get_current_screen(); if ( is_admin() && ($screen->id == ‘custom_post_type_name’) ) { function add_content_after_editor() { global $post; $id = $post->ID; echo ‘<div class=”postbox” style=”background:#0074a2;color:#fff;margin-top:20px;”><div class=”inside”>’; echo ‘Instructions go here.’; echo ‘</div></div>’; } add_action( ‘edit_form_after_title’, ‘add_content_after_editor’ ); } } add_action( ‘admin_notices’, ‘options_instructions_example’ ); It will result in something that … Read more

Get email address of type Administrator

You can use this function to get email of all the Administrator on a WordPress website function get_administrator_email(){ $blogusers = get_users(‘role=Administrator’); //print_r($blogusers); foreach ($blogusers as $user) { echo $user->user_email; } }

How to add post_author column to custom post type

The $supports argument should include author for the Author settings to be available for the custom post type: ‘supports’ => array( ‘title’, ‘custom-fields’, ‘author’ ) ‘supports’ (array) Core feature(s) the post type supports. Serves as an alias for calling add_post_type_support() directly. Core features include ‘title’, ‘editor’, ‘comments’, ‘revisions’, ‘trackbacks’, ‘author’, ‘excerpt’, ‘page-attributes’, ‘thumbnail’, ‘custom-fields’, and … Read more

Modify links under ‘help section’?

But for plugin pages,I can’t able to find the files to remove. For dealing with plugin/registered pages that you won’t necessarily know the hooks for, something like this will work… add_action( ‘admin_head’, ‘set_plugin_help_text’); function set_plugin_help_text() { global $_registered_pages; if( !empty( $_registered_pages ) ) foreach( array_keys( $_registered_pages ) as $hook ) add_contextual_help( $hook, “Your generic plugin … Read more