Code Sample: Filtering Custom Statuses by Role

We’ve received a number of requests from Edit Flow users asking for the ability to limit statuses to specific roles. While this isn’t possible via the WordPress admin, you can write a bit of code to implement this. Just add the following snippet to the functions.php file of your active theme and modify as necessary.

The code sample limits authors to only set ‘Draft’ and ‘Pitch’ statuses, whereas editors (and administrators, by omission) have access to all statuses.

 -1,
	'author' => array( 'draft', 'pitch' )
);

add_filter( 'ef_custom_status_list', 'ef_x_filter_statuses_by_role', 10, 2 );

function ef_x_filter_statuses_by_role( $statuses, $post ) {
	global $role_status_map;
	
	$role = ef_x_get_user_role();
	if( isset( $role_status_map[$role] ) && $role_status_map[$role] != -1 ) {
		$statuses = ef_x_filter_by_value( $statuses, 'slug', $role_status_map[$role] );
	}
	
	return $statuses;
}

function ef_x_get_user_role() {
	$user = wp_get_current_user();
	return array_shift( $user->roles );
}

function ef_x_filter_by_value( $array, $property, $value ) { 
	$filtered_array = array();
	foreach( (array) $array as $index => $item ) { 
		if( isset( $item->$property ) ) {
			if ( ( is_array( $value ) && in_array( $item->$property, $value ) ) || $item->$property == $value ) {
				$filtered_array[$index] = $item;
			}
		}
	} 
	return $filtered_array; 
}

v0.5.3: Duplication Bug Fix

We just pushed out v0.5.3 which fixes the duplication issue that users have been reporting. Thanks to everyone for letting us know about the issue.

You should be prompted for an upgrade from the WordPress admin, or you can download it here.

Edit Flow v0.3: Usergroups and enhanced notifications

Edit Flow was bumped up to v0.3 last week and saw a flurry of other updates as bugs cropped up that we managed to miss during the testing phase before release. The main focus of this release was to introduce usergroups, which will form the basis of future features and to enhance the notification functionality that was introduced in the previous version.

If you haven’t upgraded yet, download it from the Plugin Directory or directly from within WordPress.

Here’s a quick breakdown of the new features introduced in this release:

Usergroups

Version 0.3+ adds in what are called usergroups. On the outset, they’re similar to “Roles” built into WordPress, except that (at this stage) usergroups are simply ways to associate groups of users together. Edit Flow adds a number of sample usergroups for you to get started (as shown above) and get a sense of what sort of groupings you can create. However, the main power of usergroups comes with…

Notification Controls

Much of the feedback Edit Flow received since the email notification were introduced centered around having greater control over who receives notifications. Previously, post updates were emailed to authors, editorial commenters, and any roles that had been selected to receive notifications. Many people were drawn to the notification feature but were forced to keep it disabled since they didn’t want all their editors or administrators notified on every single post update.

With the new release, you can specify on a post level, what users and usergroups should receive notifications, so that only relevant individuals and groups of individuals receive updates.

Note: with the introduction of this feature the “Notify by Role” option was removed. In its place, a new feature was added “Always notify admin option” which includes the blog administrator in all notifications. To all overly protective, nosy admins that want to know everything: you’re welcome :)

This is just the beginning of notifications. Some interesting ideas that we’d like to integrate in future versions of Edit Flow include:

  • Giving users the ability to subscribe to posts themselves
  • Have specific users or usergroups automatically subscribed to posts based on categories or tags assinged to posts.
  • Make the UI a bit more efficient. The UI for this new feature is something that was unfortunately rushed. My original vision didn’t quite make it in (due to various impracticalities, changes, and lack of time), but it’s very much a high priority on my list to make it easy to select users/usergroups (especially for installs with hundreds and thousands of users).

More Useful Notifications

On the topic of notifications, the new release introduces emails that are slightly more descriptive in terms of the action taken on the post. The subject line of the email will specify whether the post was created, published, unpublished, etc. Although a small change, it should hopefully help users manage incoming emails more effectively and not get inundated with a barrage of “Post Status was changed” emails. (Interestingly, I’ve found that this new change comes in handy even on my personal blog which is a simple on-user blog. I find these notifications fairly useful especially since I make aggresive use of WordPress’ future scheduling functionality.)

Additionally, the action links in comment notifications now take the user directly to the editorial comment form (e.g. clicking on “Add editorial comment” will open the post and take to directly to the Editorial Comment form). Again, not a major feature but something that should hopefully save you some time, scrolling and future dealings with Carpal Tunnel.

I’d like to extend this feature even further and allow users to reply to comments via email and not have to go into WordPress to do so. (As you can see, there’s a bit a time-saving trend going on here.)

New widget: Posts I’m Following

Still a little crude at this stage, this new widget gives you a list of the most recently updated posts that you’re following. However, this widget will likely form the basis of the activity stream, which will provide an audit trail of activity happening within the WordPress admin.

Knight News Challenge Round II

While not really a feature introduced in 0.3+, here’s a bit of news that may be interest: we’ve submitted our 2nd round application for the Knight News Challenge. Check out it, vote, and leave us some feedback.

What’s Next?

Apart from some of the ideas already mentioned, with the next couple of Edit Flow releases, you can expect to see some great features such as:

  • Post task lists (a la Basecamp, namely a list of tasks that must be completed in order for a post to be published)
  • Better Post Management (to help you track and manage your content better, such as snapshots of how far along existing content is)
  • HTML emails (because emails should always be pretty — but always fallback to plain text for people still living in the ’90s)

Your Homework

As always, your feedback is much appreciated and vital to our development. Let us know what about Edit Flow works for you and what doesn’t and what else Edit Flow can do to improve your organization’s WordPress experience.

We’ve already had discussions with several online and print publishers and newsrooms interested in adopting Edit Flow and would love to include you in that conversation. Why not get in touch?

Edit Flow v0.2: Now with Post Metadata, Commenting and Notifications

The Edit Flow metabox enables editorial comments and provides some additional metadata fields to track details related to each post.

After a long hiatus, CoPress finally released v0.2 of Edit Flow this past weekend. Those who have it installed should have seen a notification to update; for those who haven’t jumped on the Edit Flow bandwagon yet, grab it from the WordPress Plugin Directory.

We’ve got some cool new features in this new version, outlined below: [Read more...]

Edit Flow Project: Stage 1 beta release

This past weekend, we released the beta version of Stage 1 (Custom Post Statuses) of the Edit Flow Project, a plugin aiming to improve the WordPress Admin Interface for a multi-user newsroom’s editorial workflow.

The main goal of this stage was to “improve posts statuses by allowing custom statuses.” WordPress, by default, only allows for two statuses for posts during the editing process: “Draft” and “Pending Review”. These statuses are not very descriptive nor do they make it easy to track a story as it moves through a newsroom’s often complex, multi-level workflow.

With the release of Stage 1 of Edit Flow, WordPress users can now assign custom statuses to posts, giving them more control over the state of their content.

Adding/Editing/Managing Custom Statuses

The interface to add, edit and manage custom statuses.

Upon activation, the plugin adds five default statuses (“Assigned”, “Draft”, “Pending Review”, “Pitch”, “Waiting for Feedback”). These can all be edited or deleted (with the exception of “Draft” and “Pending Review”, which can only be deleted). Users can also add additional custom statuses. Overall, we tried to make this as flexible as possible, acknowledging the extreme diversity in workflows and requirements across different newsrooms.

[Read more...]