Page handler

I'm currently using Elgg 2.3.14 (having issues upgrading to the latest, but that's another discussion topic) and I'm trying to register page handlers for my plugin.  I currently have two pages that I'd like to handle that are located in the following directory under my document root:



My start.php located at /var/www/html/mod/fc-plugin/start.php is as follows:


elgg_register_event_handler('init', 'system', 'fc_plugin_init');

    function fc_plugin_init() {

    elgg_register_page_handler('fc-plugin', 'fc_page_handler');

    //elgg_register_page_handler('callback', 'auth_callback_handler');

    elgg_extend_view('css/elgg', 'auth0_login/css');

    elgg_extend_view('css/elgg', 'auth_callback/css');

    elgg_extend_view('css/elgg', 'fc-plugin/css');


function fc_page_handler(array $segments) {

    echo '<script>console.log( "Debug.. made it here!" );</script>';

    $subpage = elgg_extract(0, $segments);

    if ($subpage === 'login') {

        // use login view

        echo elgg_view_resource('login');


    if ($subpage === 'auth_callback') {

    // use auth0 callback view

    echo '<script>console.log( "Debug.. made it to callback!" );</scri pt>';

    echo elgg_view_resource('auth_callback');



The login page opens correctly when called from it's initiator but the auth_callback page isn't rendering when it is called.  My auth_callback.php page has a couple of console statements that don't print to the screen but the console statement in the code above do show on the console.  I'm not quite sure why my callback page isn't rendering on the screen.  Any help would be appreciated.

  • Why don't you try this:

    function fc_page_handler($segments) {
      $page = elgg_extract(0, $segments, 'login');
      switch ($page) {
         case 'login':
             echo elgg_view_resource('login');
         case 'auth_callback':
            echo elgg_view_resource('auth_callback');
            return false;
      return true;
  • Forgot to add my callback page.  Right now it's minimal and I just want to see y console logs print, which they are not currently doing.


    echo '<script>console.log( "DEBUG: HEY HEY HEY" );</script>';

    require __DIR__ . '/vendor/autoload.php';

    // ... other use declarations use josegonzalez\Dotenv\Loader;

    // Setup environment vars

    $Dotenv = new Loader(__DIR__ . '/.env');


    use Auth0\SDK\Auth0;

    $domain = getenv('AUTH0_DOMAIN');

    $client_id = getenv('AUTH0_CLIENT_ID');

    $client_secret = getenv('AUTH0_CLIENT_SECRET');

    $redirect_uri = getenv('AUTH0_CALLBACK_URI');

    $audience = getenv('AUTH0_AUDIENCE');

    if($audience == ''){

        $audience = 'https://' . $domain . '/userinfo';


    $auth0 = new Auth0([

        'domain' => $domain,

        'client_id' => $client_id,

        'client_secret' => $client_secret,

        'redirect_uri' => '',

        'persist_id_token' => true, 'persist_access_token' => true, 'persist_refresh_token' => true,


    echo '<script>console.log( "Debug.. made it here!" );</script>';

    $userInfo = $auth0->getUser();

    if (!$userInfo) {

        // We have no user info


        elgg_echo("User couldn't be authenticated");


  • You can use:

    <?php ?>

    instead of:

    echo '<script>
  • RvR,

    I always appreciate your prompt response.  I tried replacing my fc_page_handler with yours but unfortunately looks like the same result.

  • One thing I noticed looking at my Chrome developer console... the url is:

    Status: 200

    type: document

    I'm thinking the type should be text/html

  • but unfortunately looks like the same result.

    Of course, it's works.

    the url is:

    And in the Console:

    Debug.. made it to callback!

    Works? Yes.

    What's wrong?

  • Checked my error log... guess this could be the problem:

    PHP WARNING: 2019-11-05 17:37:01 (UTC): "include(/var/www/ht ml/mod/fc-plugin/views/default/resources/auth_callback.php): failed to ope n stream: Permission denied" in file /var/www/html/vendor/elgg/elgg/engine /classes/Elgg/ViewsService.php (line 370).

    I checked the permission of auth_callback.php and it's set to:

    -rwxr-xr-x. 1 apache apache 1426 Nov 5 17:36 auth_callback.php


    not quite sure why I'm getting the permission denied issue.

  • so that debug statement is in start.php within the switch statement that handles when the page is 'auth_callback'.  The debug statements in the auth_callback.php still do not render to the console.  Sorry, that was a confusing debug statement and I can see how it could lead you to think it was working.

  • permission of auth_callback.php

    Seems, this is a problem.

    Check the permissions on another files which haven't problems and set the same rights on this file

  • Is there something else I need to do register the view for auth_callback that I may be missing?

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking