1

I need to always redirect authenticated users to a different page (to serve as their own frontpage) whenever they try to access the default (anonymous) frontpage. I want to achieve this using rules or through some custom php code in my template.php or settings.php file, NOT by enabling a new module. Thanks.

Added: i created the frontpage using Page Manager (packaged with ctools)

0

If you are using a particular node as your front page:

  1. Create a new rule, event: content is viewed
  2. Condition: data comparison -> node:nid equals to the nid of your front page node.
  3. Add your conditions for user roles here.
  4. Action: page redirect -> enter the path where you want to redirect the users

If you have PHP code module enabled already:

  1. Create a new rule, event: content is viewed
  2. Condition: execute custom PHP code -> return drupal_is_front_page();
  3. Add your conditions for user roles here.
  4. Action: page redirect -> enter the path where you want to redirect the users
  • I am not using a node as my front page, i created the frontpage using page manager. – IT Pro Manager Nov 10 '13 at 15:44
  • Do you have PHP code module enabled already? – Aram Boyajyan Nov 10 '13 at 15:45
  • Yes i have PHP module enabled – IT Pro Manager Nov 10 '13 at 15:46
  • Then did you try the second solution I posted? That one works for any type of front pages. – Aram Boyajyan Nov 10 '13 at 15:46
  • This didnt work, i have now found a solution. Thanks for suggestions. – IT Pro Manager Nov 11 '13 at 23:33
0

I have been able to resolve this using rules bonus pack: https://drupal.org/project/rb

The module to enable is Rules bonus: miscellaneous.

Each panel page now gets an extra tab below other tabs (like Layout, content, Preview) called "Reactions" => "Create a rules event for this variant". After enabling this and saving, Go to your rules events, a new rules event will be added "Rules Bonus: Miscellaneous" => "variant panel is rendered". Select this and save.

Conditions: User has roles (authenticated)

Actions: Page redirect: enter the path to the page e.g. "newpage" (without quotes).

0

For me, "Content is viewed" would not work because I use the default front page, which is not a content node. It probably works if you are using a particular content node as front page.

For me, this worked on Drupal 7.59, Rules 7.x-2.9:

  1. Create a new rule, event: Drupal is initializing

  2. Condition: Text comparison between data selector [site:current-page:url] and matching text (here I used PHP):

    $front_url = 'https://example.org' . url();

    echo $front_url

The text comparison evaluates to TRUE when Drupal is initalizing the default front page, because my home url is 'https://example.org/drupaldirectory/'

  1. Add your conditions for user roles here

  2. Action: page redirect: enter the path where you want to redirect users

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.