Skip to main content
added 573 characters in body
Source Link
Felix Eve
  • 6.3k
  • 2
  • 25
  • 57

JustGiving users permission to view unpublished content could potentially be a security risk, and it's not (easily) possible to restrict it to just viewing a particular content type.

Why not publish the node, but only allow users with a certain role be able to view them using the Content Access module.

Then create a few accounts with this role, setting the usernames and passwords yourself.

Then just use the standard Drupal login form but then alter the redirect once logged in with hook_user_login:

function hook_user_login(&$edit, $account) {
    if (in_array('your_role', $account->roles)) {
        $edit['redirect'] = 'node/123';
    }
}

Of courseBy creating the accounts this way it means you will need to give authenticated userscan use the permissionmain Drupal authentication system so reducing the amount of work that you need to see unpublished pagesdo...

Just use the standard Drupal login form but then alter the redirect once logged in with hook_user_login:

function hook_user_login(&$edit, $account) {
  $edit['redirect'] = 'node/123';
}

Of course you will need to give authenticated users the permission to see unpublished pages.

Giving users permission to view unpublished content could potentially be a security risk, and it's not (easily) possible to restrict it to just viewing a particular content type.

Why not publish the node, but only allow users with a certain role be able to view them using the Content Access module.

Then create a few accounts with this role, setting the usernames and passwords yourself.

Then just use the standard Drupal login form but then alter the redirect once logged in with hook_user_login:

function hook_user_login(&$edit, $account) {
    if (in_array('your_role', $account->roles)) {
        $edit['redirect'] = 'node/123';
    }
}

By creating the accounts this way it means you can use the main Drupal authentication system so reducing the amount of work that you need to do...

Source Link
Felix Eve
  • 6.3k
  • 2
  • 25
  • 57

Just use the standard Drupal login form but then alter the redirect once logged in with hook_user_login:

function hook_user_login(&$edit, $account) {
  $edit['redirect'] = 'node/123';
}

Of course you will need to give authenticated users the permission to see unpublished pages.