0

I have an app in Drupalgap. I would like to display a different frontpage for anonymous users and authenticated users, for example /dashboard for the first and /user_listing for the last.

I have read "Display Different Text for Anonymous and Authenticated Users", but it is not the same scenario. (/user_listing has ['access user profiles'] as access_arguments.)

I also have tried with drupalgap_goto() without succeed.

How can it be done?

3 Answers 3

1

You can achieve this using Context Reaction: Front page module, which extends the great Context module.

Create a new context and:

  1. Add a condition for User role
  2. Add a reaction Front page putting the path for the roles you want to affect.

Save the context and all should be done.

2
  • Sorry but I was talking about DrupalGap, not drupal core
    – Alfonso_MA
    Aug 25, 2017 at 11:25
  • Well, no experience there, sorry. :(
    – kufeiko
    Aug 25, 2017 at 12:50
1

You can use the same page for both, and then render different things depending on if they are logged in or not:

function my_front_page_callback() {
  var content = {};
  if (!Drupal.user.uid) {
    content.foo = {
      markup: '<p>You are NOT logged in...</p>'
    };
  }
  else {
    content.bar = {
      markup: '<p>You are logged in...</p>'
    };
  }
  return content;
}
-1

drupalgap_goto() worked for me.

I have front page set to go to qleva_start which has this page callback:

function qleva_start_page() {
  try {
    if (drupalgap_user_has_role('authenticated user')) {
      drupalgap_goto('qleva_start_auth');
    }
    else {
      drupalgap_goto('user/login');
    }
  }
  catch (error) { console.log('qleva_start - ' + error); }
} 

so if anon, front is login page and if authenticated, it is qleva_start_auth

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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