I've looked through all the issue queues and forums and can't seem to find this functionality in workbench. The use case is this:

People who have logged into our policy site are set as authenticated users. They need to be able to view drafts but that's it. I don't want them to move the draft to any other state. Just view.

Based on this post (https://drupal.org/node/1492118) it looks like the only way to do this is to enable the global access permission (Node: Bypass content access control ) which overrides all other access. But if I don't do that, then I get access denied when I go to a draft page as an authenticated user.

I have enabled the Workbench Moderation permissions "View all unpublished content" prior to setting the above permission and that did nothing. I also enabled the View Unpublished module and set those permissions with no luck.

I'm wondering if this is even possible or if there is something I'm missing in the setup. Any help is appreciated.

Comments

ginosuave’s picture

I got here by googling "Drupal authenticated user view draft". All I'm trying to do is allow authenticated users to view Draft content. Tried both the "View all unpublished content" and "View content revisions" permissions with no success.

ginosuave’s picture

This issue can be resolved by writing a custom module that contains the following code, copied from pandaeskimo here: https://www.drupal.org/node/1461950#comment-7492746

/**
 * Implements hook_workbench_moderation_access_alter().
 */
function draft_staging_workbench_moderation_access_alter(&$access, $op, $node) {
  if ($op == 'view revisions' && user_access('view revisions')) {
    $access = TRUE;
  }
}

If you're trying to build a staging environment using drafts like we were (and are using path aliases with Global Redirect), you should include these hooks and javascript as well, so that draft content links to other draft content.

/**
 * Implements hook_url_outbound_alter().
 */
function draft_staging_url_outbound_alter(&$path, &$options, $original_path) {
  // Internal URLs only.
  if (!$options['external']) {
  	// Check if current page is draft page.
  	if (preg_match('|/draft/?$|', current_path())) {
      $options['alias'] = $path;
    }
  }
}

/**
 * Implements hook_preprocess_page().
 */
function draft_staging_preprocess_page(&$variables) {
  // Check if current page is draft page.
  if (preg_match('|/draft/?$|', current_path())) {
  	drupal_add_js(drupal_get_path('module', 'draft_staging') .'/draft_staging.js');
  }
}

And some javascript (draft_staging.js):

(function ($) {
	$(window).load(function() {
		$('.node__content a').each(function(){
			var href = $(this).attr('href');
			//Internal URLs only.
			if (!href.match(/^(https?:)?\/{2}/)) {
				$(this).attr('href', href+'/draft');
			};
		});
	});
})(jQuery);