Front_page redirect for Authenticated 4.7.x

jbraun - February 4, 2007 - 16:09
Project:Front Page
Version:5.x-1.8
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Dublin Drupaller
Status:active
Description

I have two roles - Anonymous and "Teacher". I have one user in the teacher role. For anonymous users, I want one page. For authenticated, another. I created two pages. Page 1 is called "guest" (via clean url). Page 2 is called "teacher". In front page I set the anonymous to redirect to "guest" and authenticated to redirect to "teacher". Anonymous works perfectly. But authenticated gives the same page (does not redirect to the "teacher" page).

Help is much appreciated.

#1

Dublin Drupaller - February 6, 2007 - 11:21
Status:active» postponed

In previous versions, the front page redirect would automatically pick up those redirect settings, but, there have been changes made to the Drupal core that affects the login process which means that it doesn't work as it used to:

http://drupal.org/node/83822

those changes to core have thrown up a lot of problems in other areas, that are probably more pressing than the impact on the front_page.module, so I haven't been screaming about it. Once those problems are sorted, I'll revisit the front page redirects to see how I can get the front_page to work with the new changes.

In the meantime, use the Front_page setting for ANONYMOUS USERS to setup your anonymous node. In other words, don't use direct for anonymous users.

i.e. what will work is the following:

(a) for your 'guest' page go to ADMINISTER -> SETTINGS -> FRONT PAGE and in the text area setting for anonymous users, paste in your "guest" node content and select themed.

(b) for you other front pages, like teacher, student etc. use as normal. there is a new feature that allows you to specify front pages based on role type, so it will be easier for you now to setup different front pages for different role types.

I hope that helps and makes sense. I'll revist the front_page.module redirects when the login issues are sorted. In the meantime, just use the procedure outlined.

Dub

p.s. I'm closing off this issue as it's a duplicate of others. open it back up by posting a reply and selecting ACTIVE in the status option.

#2

jbraun - February 6, 2007 - 12:22

That method works. However, I'd like the guest user to be able to comment. Redirecting to page allows this. The work around doesn't. Any creative solution?

Thanks,
Josh

#3

Dublin Drupaller - February 6, 2007 - 15:35

hi Josh,

if you insert a snippet to display the full node, it should pull up the links/comments for you. example below:

Change the $display_node_id value to the node id of the node you want to display

<h1 class="title">page title</h1>
<?php
$display_node_id
= '4';
$output = node_view(node_load(array('nid' => $display_node_id)), 1,1,1);
print
$output;
?>

For your reference the node_view syntax and options are as follows:

node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE)

Remember to select ALLOW EMBEDDED PHP option before saving your front page settings!

I hope that helps.

Dub

#4

Dublin Drupaller - February 6, 2007 - 15:39
Title:Redirect for Authenticated 4.7» Front_page redirect for Authenticated 4.7.x
Assigned to:Anonymous» Dublin Drupaller
Status:postponed» active

just re-opening this issue to make it more visible for others.

Dub

#5

jbraun - February 6, 2007 - 16:24

Dub,
Geez, you make this stuff sound so easy. This worked perfectly. I'm assuming this method will also work if I want to send authenticated users belonging to different groups to different pages? Let me guess. . .. another snippet right? Can you point me in the right direction?

Thanks again!!!!

Josh

#6

jbraun - February 6, 2007 - 16:27

I meant roles, not groups.

#7

Dublin Drupaller - February 6, 2007 - 18:44

Good point (about displaying a front page for groups instead of roles) and good idea..I'll add it to the feature list along the lines of:

(a) on the settings page, check to see if the organic groups module is installed.
(b) if it is, switch the logic to allow site admin specify front page by group instead of role.

Anyway. getting back to your question.....and please note I haven't tested this, but, here's the bones of a snippet that should work:

<?php
  $group_title1
= 'teacher'
 
$group_title2 = 'students'
  global
$user;
  if(
$user->uid) {   // Double check the user is logged in
    
if( $user->og_groups ) { //check to see if they are assigned a group     
       
foreach( $user->og_groups as $gid => $group ){
          if (
strstr($group['title'], $group_title1 ) ) { // check for teachers group
            
print 'content for teachers goes here'; // display this stuff
              
}
          if (
strstr($group['title'], $group_title2 ) ) { // check for students group
            
print 'content for students goes here'; // display this stuff
              
}
            }
         }
     }
?>

Of course you could combine this with the earlier snippet, to display a specific node, instead of pasting content into the snippet. e.g.

<?php
  $group_title1
= 'teacher'
 
$teachers_node = "4";
 
$group_title2 = 'students'
 
$students_node = "5";
  global
$user;
  if(
$user->uid) {   // Double check the user is logged in
    
if( $user->og_groups ) { //check to see if they are assigned a group     
       
foreach( $user->og_groups as $gid => $group ){
          if (
strstr($group['title'], $group_title1 ) ) { // check for teachers group
            
print '<h1 class="title">Teachers node title</h1>';
             print
node_view(node_load(array('nid' => $teachers_node)), 1,1,1);
               }
          if (
strstr($group['title'], $group_title2 ) ) { // check for students group
            
print '<h1 class="title">Students node title</h1>';
             print
node_view(node_load(array('nid' => $students_node)), 1,1,1);
               }
            }
         }
     }
?>

Don't forget to select ALLOW EMBEDDED PHP when saving your front_page settings.

can you post back up here if either works for you?

Dub

#8

nipsy - February 7, 2007 - 00:56

Dub,
here's hoping the issues are worked out soon.
My issue is with auth users not being recognized.
Read the posts and tried to put Panel display code in the html section of anonymous user:

<?php
$did
= 1;
print
panels_panels_page($did);
?>

nothing shows up
additionally in the bottom most setting to enable the plug, I used to have "front_page" because that's what the directions say, but through trying to make it all work, I put the title of the default page I want to show. It didn't do anything for me, but if I put "front_page" back there the default comes up blank.

I never had an alias page called front_page, is it somewhere in the database now?

At best, using the settings from last version, it would show anon default, even after logging in (covered in other posts) but after that, clicking on Home breadcrumb redirected to appropriate authorized user page.

Now nothing works and I set basic unauth page via lower most entry.

#9

nipsy - February 7, 2007 - 02:26

Could I hard code the unauth and auth front pages?

#10

gjk - March 9, 2007 - 10:14
Version:4.7.x-4.0» 5.x-1.8

Not sure if this is the same problem, but I am experiencing a problem with redirecting with any role. I created a separate login page, http://www.example.com/login. Now, whatever I try to do the front page module never redirects from this login page. I tried changing anonymous user to "Themed", but alas, it does not work.

Anonymous users go correctly to the front page, http://www.example.com/node, but nothing seems to work for authenticated users. What I am trying to do is get each role to redirect to their correct organic group page.

BTW, I am using Drupal 5.0, just looked like this was the same problem.

#11

Magdelaine - March 21, 2007 - 19:51

I have this exact problem; login via login page results in user/userid with the "home" breadcrumb pointed to the right page, but no redirect.

v.5.1

#12

kris_n4 - March 26, 2007 - 05:58

i use view instead of node. tested on front 5.x.1.8

<?php
$view_name
= 'myview'; //name of view
$limit = 3; // number of returns
$view_args = array();
print
views_build_view('embed', views_get_view($view_name), $view_args, FALSE, $limit);
?>

#13

bmadore - August 7, 2007 - 16:08

Just wanted to follow up on nipsy's request for info on php code to put the content of a Panel on the front page rather than a node or view as posted by others. A slight modification of the code you posted worked for me-- basically the insertion of a "print" command. Now, I'm not a php coder nor do I play one in any podcast but this code works for me:

<?php
$did
= 1;
print
panels_panels_page($did);
?>

The did is the id for the panel you wish to display, of course. Another caveat: you are inserting a panel (if my language is correct technically) into the body of the page rather than having the panel be the sole content of the page. This means that if you make blocks visible for anonymous users, and don't note that they shouldn't show on your page, then these blocks will show up on the page beneath the panel. Likewise, I think but haven't tested, content that is promoted to the will show in the same area if not prevented from doing so.

--barry madore
--advantage labs
--minneapolis, mn

 
 

Drupal is a registered trademark of Dries Buytaert.