Show Authors Their Own Posts in Admin

You can redirect the normal All Posts pages to a version that only displays the current user’s posts. (Similar to this post). Users will not be able to get back to the ‘all’ view, as in the other sample. Users are not prevented from changing the author ID in the URL and viewing another user’s posts.

add_action( 'load-edit.php', 'posts_for_current_author' );
function posts_for_current_author() {
	global $user_ID;

	/*if current user is an 'administrator' do nothing*/
	//if ( current_user_can( 'add_users' ) ) return;

	/*if current user is an 'administrator' or 'editor' do nothing*/
	//if ( current_user_can( 'edit_others_pages' ) ) return;

	if ( ! isset( $_GET['author'] ) ) {
		wp_redirect( add_query_arg( 'author', $user_ID ) );
		exit;
	}

}

Removed Categories Dropdown Filter

On the All Posts page, there are a series of filters for narrowing down what posts are displayed.

To remove the categories filter, use this:

add_action( 'load-edit.php', 'no_category_dropdown' );
function no_category_dropdown() {
	add_filter( 'wp_dropdown_cats', '__return_false' );
}

In the action hook, change ‘edit.php’ if you want to remove the dropdown on other pages.

Remove Bulk Actions Dropdown

To remove the bulk actions dropdown menu, you simply need to remove all actions! Just hook in and replace the default actions array with an empty array.

add_filter( 'bulk_actions-' . 'edit-post', '__return_empty_array' );

In this case, only the bulk actions menu on the All Posts page will be removed. To use elsewhere, replace ‘edit-post’ with the screen ID.

Default All Posts to the Current User’s Posts

When clicking on All Posts in the main menu, Administrators and Editors will normall see all posts. Use this to change the default view to the user’s own posts. See comments to limit the change to users of a certain roll.

add_action( 'admin_menu', 'show_users_posts_by_default' );
function show_users_posts_by_default() {

	/*if current user is an 'administrator' do nothing*/
	//if ( current_user_can( 'add_users' ) ) return;

	/*if current user is an 'administrator' or 'editor' do nothing*/
	//if ( current_user_can( 'edit_others_pages' ) ) return;

	global $submenu, $user_ID;
	$submenu['edit.php'][5][2] = 'edit.php?author='. $user_ID;
}

Remove IM Fields From Profile Page

Need to declutter the profile options by removing the various IM fields. It’s easy

add_filter('user_contactmethods', 'remove_im_options', 10, 2); 
function remove_im_options( $user_contactmethods, $user ) {
    unset($user_contactmethods['aim']);
    unset($user_contactmethods['yim']);
    unset($user_contactmethods['jabber']);
    //$user_contactmethods = array();
    return $user_contactmethods;
}

Add Extra Content to the Widgets Admin

I don’t have a good example of why you might want or need this, but nevertheless, if you should want to add additional text to the Widgets admin, it’s pretty darn easy:

add_action( 'widgets_admin_page', 'widgets_admin_info' );
function widgets_admin_info() {
    ?>
    <p style="clear:both;">Hello there!!</p>
    <?php
}

Add New Dashboard Widget

Add a new widget to the dashboard. Note, this will add the widget to the bottom of the page. If you want to try to move it to the top, check out the Codex page about dashboard widgets

add_action('wp_dashboard_setup', 'add_custom_dash_boxes');
function add_custom_dash_boxes() {
    wp_add_dashboard_widget( 
        'welcome_box',
        __( 'Welcome', 'myplugin_textdomain' ),
        'welcome_box_text'
    );
}
function welcome_box_text() {
    echo 'Custom welcome text here';
}

Remove Unwanted Dashboard Widgets

If you feel your dashboard is too cluttered, you can use this to remove any or all of the widgets

add_action( 'wp_dashboard_setup', 'remove_wp_dashboard_widgets' );
function remove_wp_dashboard_widgets() {
	//Plugins
	wp_unregister_sidebar_widget( 'dashboard_plugins' );
	remove_meta_box('dashboard_plugins', 'dashboard', 'normal');

	//Right Now
	//wp_unregister_sidebar_widget( 'dashboard_right_now' );
	//remove_meta_box('dashboard_right_now', 'dashboard', 'normal');

	//Recent Comments
	//wp_unregister_sidebar_widget( 'dashboard_recent_comments' );
	//remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');

	//Incoming Links
	//wp_unregister_sidebar_widget( 'dashboard_incoming_links' );
	//remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal');

	//WordPress Blog
	wp_unregister_sidebar_widget( 'dashboard_primary' );
	remove_meta_box('dashboard_primary', 'dashboard', 'side');

	//Other WordPress News
	wp_unregister_sidebar_widget( 'dashboard_secondary' ); 
	remove_meta_box('dashboard_secondary', 'dashboard', 'side');

	//Quick Press
	//wp_unregister_sidebar_widget( 'dashboard_quick_press' ); 
	//remove_meta_box('dashboard_quick_press', 'dashboard', 'side');

	//Recent Drafts
	//wp_unregister_sidebar_widget( 'dashboard_recent_drafts' ); 
	//remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side');
}

Add A Security Question to the Register Screen

Want to allow people to register on your site, but don’t want to be flooded with spam users? Try this:

add_action( 'register_form', 'add_register_field' );
function add_register_field() { ?>
	<p>
		<label><?php _e('What is the name of the ship in the TV show Firefly?') ?><br />
		<input type="text" name="user_proof" id="user_proof" class="input" size="25" tabindex="20" /></label>
	</p>
<?php }

add_action( 'register_post', 'add_register_field_validate', 10, 3 );
function add_register_field_validate( $sanitized_user_login, $user_email, $errors) {
	if (!isset($_POST[ 'user_proof' ]) || empty($_POST[ 'user_proof' ])) {
		return $errors->add( 'proofempty', '<strong>ERROR</strong>: You did not answer the proof-of-humanship question.'  );
	} elseif ( strtolower( $_POST[ 'user_proof' ] ) != 'serenity' ) {
		return $errors->add( 'prooffail', '<strong>ERROR</strong>: You did not answer the proof-of-humanship question correctly.'  );
	}
}

This adds an extra box to the register screen with the question “What is the name of the ship in the TV show Firefly?” The user-provided answer is then compared to the official answer. If correct, the user is registered, otherwise WordPress-friendly error(s) are returned.