Plugin Planet

Premium WordPress Plugins

This tutorial provides code snippets to customize the USP Pro Dashboard Widget. These are all plug-&-play functions that can be added to your theme’s functions.php file, or added via your own custom plugin.

By default, the Dashboard Widget displays all submitted posts that meet the following criteria:

  • Posts submitted by the current logged-in user
  • Any of the following post statuses: Draft, Future, Pending
  • Any of the following post types: Posts, Pages, USP Posts

Below you will find code snippets to customize each of these criteria. So for example, you can display the widget to all logged-in users, and include additional post types and post statuses (statii). Or whatever combination that’s required.

Display widget to all logged-in users

To display the Dashboard Widget to all logged-in users, add the following code snippet to your theme’s functions.php file:

// USP Pro - show Dashboard Widget to all users
function usp_dashboard_widget_custom_user() { return ''; }
add_filter('usp_widget_drafts_user', 'usp_dashboard_widget_custom_user');

No modifications are required, simply upload and done. Notice that this function returns an empty string to the usp_widget_drafts_user filter, which then will query submitted posts for all users. By changing the return value, it would be possible to display the widget to any user or set of users. Check out the WP_Query Author Parameters for more possibilities.

Include posts from any post type

To include posts from additional post type(s), add the following code snippet to your theme’s functions.php file:

// USP Pro - Dashboard Widget include post types
function usp_dashboard_widget_custom_post_type() {
	return array('post', 'page', 'usp_post', 'my-post-type');
}
add_filter('usp_widget_drafts_type', 'usp_dashboard_widget_custom_post_type');

Before uploading this code, make sure to edit the returned array, replacing my-post-type with the name of the post type that you would like to add. Check out the Custom Post Types tutorial for more information. Also check out the WP_Query Type Parameters for more ideas.

Include posts of any post status

To include posts of any post status, add the following code snippet to your theme’s functions.php file:

// USP Pro - Dashboard Widget include post status
function usp_dashboard_widget_custom_post_status() {
	return array('draft', 'future', 'pending', 'publish');
}
add_filter('usp_widget_drafts_status', 'usp_dashboard_widget_custom_post_status');

Before uploading this code, make sure to edit the returned array, replacing publish with the name of the post status that you would like to add. Check out the Custom Post Status tutorial for more information. Also check out the WP_Query Status Parameters for more ideas.