How to remove a column from the Posts page

function my_manage_columns( $columns ) { unset($columns[‘date’]); return $columns; } function my_column_init() { add_filter( ‘manage_posts_columns’ , ‘my_manage_columns’ ); } add_action( ‘admin_init’ , ‘my_column_init’ );

Filter by custom field in custom post type on admin page

And for displaying result for Filter then try this code add_filter( ‘parse_query’, ‘prefix_parse_filter’ ); function prefix_parse_filter($query) { global $pagenow; $current_page = isset( $_GET[‘post_type’] ) ? $_GET[‘post_type’] : ”; if ( is_admin() && ‘competition’ == $current_page && ‘edit.php’ == $pagenow && isset( $_GET[‘competition-name’] ) && $_GET[‘competition-name’] != ” ) { $competition_name = $_GET[‘competition-name’]; $query->query_vars[‘meta_key’] = ‘competition_name’; … Read more

How do I remove dashboard access from specific user roles?

To lock subscribers and contributors out of the admin: function wpse23007_redirect(){ if( is_admin() && !defined(‘DOING_AJAX’) && ( current_user_can(‘subscriber’) || current_user_can(‘contributor’) ) ){ wp_redirect(home_url()); exit; } } add_action(‘init’,’wpse23007_redirect’); Hope that helps. All roles give the user a capability that is the name of that role, so you can use any role name as a capability.

How to remove entire admin menu?

The correct hook to use is admin_menu and then create a function to remove the menus you want to remove. The following 2 functions remove all the menus. add_action( ‘admin_menu’, ‘remove_admin_menus’ ); add_action( ‘admin_menu’, ‘remove_admin_submenus’ ); //Remove top level admin menus function remove_admin_menus() { remove_menu_page( ‘edit-comments.php’ ); remove_menu_page( ‘link-manager.php’ ); remove_menu_page( ‘tools.php’ ); remove_menu_page( ‘plugins.php’ … Read more

How do I get the current edit page ID in the admin?

You can also use $post_id = $_GET[‘post’]; Or you can use a hook (probably better). function id_WPSE_114111() { global $post; $id = $post->ID; // do something } add_action( ‘admin_notices’, ‘id_WPSE_114111’ ); You will need to add a conditional since this will run on all admin pages, I recommend using get_current_screen(); For example to run only … Read more

Customize Edit Post screen for Custom Post Types?

Some of these questions are answered here: Set Default Admin Screen options & Metabox Order To remove the permalink metabox: function my_remove_meta_boxes() { remove_meta_box(‘slugdiv’, ‘my-post-type’, ‘core’); } add_action( ‘admin_menu’, ‘my_remove_meta_boxes’ ); additionaly, you will have to hide #edit-slug-box with css or javascript. see: Loading External Scripts in Admin but ONLY for a Specific Post Type? … Read more

Give Editor Access To Sidebar

The edit_theme_options capability should allow the user to edit the sidebar as described on this page : http://codex.wordpress.org/Appearance_Widgets_SubPanel Code to add to functions.php $role = get_role(‘editor’); $role->add_cap(‘edit_theme_options’); Edit: This should work to prevent editor accessing themes or menus function custom_admin_menu() { $user = new WP_User(get_current_user_id()); if (!empty( $user->roles) && is_array($user->roles)) { foreach ($user->roles as $role) … Read more

Remove update nags for non-admins [duplicate]

In wp-admin/includes/update.php file if ( current_user_can(‘update_core’) ) $msg = sprintf( __(‘An automated WordPress update has failed to complete – <a href=”https://wordpress.stackexchange.com/questions/231010/%s”>please attempt the update again now</a>.’), ‘update-core.php’ ); else $msg = __(‘An automated WordPress update has failed to complete! Please notify the site administrator.’); We can see that messages are different based on the current … Read more

How do i know the current post type when on post.php in admin?

add_action( ‘admin_init’, ‘do_something_152677’ ); function do_something_152677 () { // Global object containing current admin page global $pagenow; // If current page is post.php and post isset than query for its post type // if the post type is ‘event’ do something if ( ‘post.php’ === $pagenow && isset($_GET[‘post’]) && ‘post’ === get_post_type( $_GET[‘post’] ) ) … Read more

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