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


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.

  • 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

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;

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')) {
    else {
  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 that you have read and understand our privacy policy and code of conduct.

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