Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Any to give users their own selection of homepage layout?

24

Comments

  • DoyceTDoyceT ✭✭✭

    Guys, peregrine's tweaks worked perfectly. I can't thank you enough for your help on this.

  • @DoyceT said:
    Guys, peregrine's tweaks worked perfectly. I can't thank you enough for your help on this.

    Here's another mod. so when the user looks their selections again in edit profile, it shows what they previously selected.

    there might be a cleaner way but this works for me.

            public function ProfileController_EditMyAccountAfter_Handler($Sender) {
    
    
                $ControllerOptions = array(
                    'discussions' => 'Discussion List',
                    'categories' => 'Category List'
                );
                $CLayoutOptions = $DLayoutOptions = array(
                    'modern' => T('Modern non-table-based layout'),
                    'table' => T('Classic table layout used by traditional forums')
                );
                $CLayoutOptions['mixed'] = T('All categories listed with a selection of 5 recent discussions under each');
    
        // retrieve previously selected values.
    
                if ($ControllerSelected = $this->GetUserMeta($Sender->User->UserID, 'DefaultController')) {
                    $ControllerSelected = array_values($ControllerSelected);
                    $dvalue = getvalue($ControllerSelected[0], $ControllerOptions);
                    $dunshift = $ControllerSelected[0] = $dvalue;
                    array_unshift($ControllerOptions, $dunshift);
                }
    
                if ($DiscussionsLayout = $this->GetUserMeta($Sender->User->UserID, 'DiscussionsLayout')) {
    
                    $DiscussionsLayout = array_values($DiscussionsLayout);
                    $dvalue = getvalue($DiscussionsLayout[0], $DLayoutOptions);
                    $dunshift = $DiscussionsLayout[0] = $dvalue;
                    array_unshift($DLayoutOptions, $dunshift);
                }
                if ($CategoriesLayout = $this->GetUserMeta($Sender->User->UserID, 'CategoriesLayout')) {
                    $CategoriesLayout = array_values($CategoriesLayout);
                    $dvalue = getvalue($CategoriesLayout[0], $CLayoutOptions);
                    $dunshift = $CategoriesLayout[0] = $dvalue;
                    array_unshift($CLayoutOptions, $dunshift);
                }
    
    
    
                echo '<li class="Homepage">';
                echo $Sender->Form->Label('Homepage View', 'DefaultController');
                echo $Sender->Form->DropDown('DefaultController', $ControllerOptions);
                echo $Sender->Form->Label('Discussions View', 'DiscussionsLayout');
                echo $Sender->Form->DropDown('DiscussionsLayout', $DLayoutOptions);
                echo $Sender->Form->Label('Categories View', 'CategoriesLayout');
                echo $Sender->Form->DropDown('CategoriesLayout', $CLayoutOptions);
                echo '</li>';
            }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • DoyceTDoyceT ✭✭✭
    edited June 2014

    I like this idea. This would go in as basically a fourth public function in the plugin?

    Edit: Sorry, I see - it's a change to the second Public function already in the plugin.

  • DoyceTDoyceT ✭✭✭

    The only bit of weird behavior I'm seeing is that if I log in as Admin and change the settings in the profile page, it seems to change the defaults in the Dashboard. (But if I change the Dashboard, it doesn't change the Admin settings in the Admin profile.)

    Hardly a real problem, but an interesting drug interaction.

  • peregrineperegrine MVP
    edited June 2014

    I like this idea. This would go in as basically a fourth public function in the plugin?

    no, a replacement for the existing function.

    The only bit of weird behavior I'm seeing is that if I log in as Admin and change the settings in the profile page, it seems to change the defaults in the Dashboard. (But if I change the Dashboard, it doesn't change the Admin settings in the Admin profile.)

    But if I change the Dashboard, it doesn't change the Admin settings in the Admin profile

    it shouldn't as you would hope,

    The only bit of weird behavior I'm seeing is that if I log in as Admin and change the settings in the profile page, it seems to change the defaults in the Dashboard

    You would need to put a check in Public function UserModel_AfterGetSession_Handler($Sender) {

    to return immediately if you are viewing dashboard.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • DoyceTDoyceT ✭✭✭
    edited June 2014

    Gotcha.

    And, as I said, really that's an entirely manageable feature of the plug-in.

    So, just for the sake of historical record, here's the full plugin file I ended up with, in case it's of use to anyone else.

    /plugins/CustomHomepage/class.customhomepageplugin.php

    <?php if (!defined('APPLICATION')) exit(); ?>
    
    <?php
    $PluginInfo['CustomHomepage'] = array(
       'Name' => 'Custom Homepage',
       'Description' => 'This plugin allows users to set their own choices for which homepage view and style they will see when they connect to the forum.',
       'Version' => '0.1',
       'Author' => "Doyce Testerman - but really peregrine and hgtonight",
       'AuthorEmail' => 'doyce.testerman@gmail.com',
       'AuthorUrl' => 'http://nila.edu'
    );
    ?>
    
    <?php
    class CustomHomepagePlugin extends Gdn_Plugin {
    
    public function UserModel_AfterGetSession_Handler($Sender) {
        $User = $Sender->EventArguments['User'];
        // override the default controller route temporarily if it has been set
        $Controller = $this->GetUserMeta($User->UserID, 'DefaultController', FALSE, TRUE);
        if($Controller) {
        Gdn::Router()->SetRoute('DefaultController', $Controller, 'Internal', FALSE);
        }
        // override the default layout temporarily
        if($DiscussionsLayout =$this->GetUserMeta($User->UserID, 'DiscussionsLayout')) {
        $DiscussionsLayout = array_values($DiscussionsLayout);
        SaveToConfig('Vanilla.Discussions.Layout',GetValue(0,$DiscussionsLayout) , array('Save' => FALSE));
        }
        if($CategoriesLayout =$this->GetUserMeta($User->UserID, 'CategoriesLayout')) {
        $CategoriesLayout = array_values($CategoriesLayout);
        SaveToConfig('Vanilla.Categories.Layout', GetValue(0, $CategoriesLayout), array('Save' => FALSE));
        }
        }
    
    public function ProfileController_EditMyAccountAfter_Handler($Sender) {
        $ControllerOptions = array(
        'discussions' => 'Discussion List',
        'categories' => 'Category List'
        );
        $CLayoutOptions = $DLayoutOptions = array(
        'modern' => T('Modern non-table-based layout'),
        'table' => T('Classic table layout used by traditional forums')
        );
        $CLayoutOptions['mixed'] = T('All categories listed with a selection of 5 recent discussions under each');
    
        // retrieve previously selected values.
    
        if ($ControllerSelected = $this->GetUserMeta($Sender->User->UserID, 'DefaultController')) {
        $ControllerSelected = array_values($ControllerSelected);
        $dvalue = getvalue($ControllerSelected[0], $ControllerOptions);
        $dunshift = $ControllerSelected[0] = $dvalue;
        array_unshift($ControllerOptions, $dunshift);
        }
        if ($DiscussionsLayout = $this->GetUserMeta($Sender->User->UserID, 'DiscussionsLayout')) {
        $DiscussionsLayout = array_values($DiscussionsLayout);
        $dvalue = getvalue($DiscussionsLayout[0], $DLayoutOptions);
        $dunshift = $DiscussionsLayout[0] = $dvalue;
        array_unshift($DLayoutOptions, $dunshift);
        }
        if ($CategoriesLayout = $this->GetUserMeta($Sender->User->UserID, 'CategoriesLayout')) {
        $CategoriesLayout = array_values($CategoriesLayout);
        $dvalue = getvalue($CategoriesLayout[0], $CLayoutOptions);
        $dunshift = $CategoriesLayout[0] = $dvalue;
        array_unshift($CLayoutOptions, $dunshift);
        }
    
        echo '<li class="Homepage">';
        echo $Sender->Form->Label('Homepage View', 'DefaultController');
        echo $Sender->Form->DropDown('DefaultController', $ControllerOptions);
        echo $Sender->Form->Label('Discussions View', 'DiscussionsLayout');
        echo $Sender->Form->DropDown('DiscussionsLayout', $DLayoutOptions);
        echo $Sender->Form->Label('Categories View', 'CategoriesLayout');
        echo $Sender->Form->DropDown('CategoriesLayout', $CLayoutOptions);
        echo '</li>';
        }
    
    public function UserModel_AfterSave_Handler($Sender) {
        $FormValues = $Sender->EventArguments['FormPostValues'];
        $UserID = val('UserID', $FormValues, 0);
        // Require valid user ID
        if(!is_numeric($UserID) || $UserID <= 0) {
        return;
        }
        $DefaultController = val('DefaultController', $FormValues, FALSE);
        if($DefaultController) {
        $this->SetUserMeta($UserID, 'DefaultController', $DefaultController);
        }
        $DiscussionsLayout = val('DiscussionsLayout', $FormValues, FALSE);
        if($DiscussionsLayout) {
        $this->SetUserMeta($UserID, 'DiscussionsLayout', $DiscussionsLayout);
        }
        $CategoriesLayout = val('CategoriesLayout', $FormValues, FALSE);
        if($CategoriesLayout) {
        $this->SetUserMeta($UserID, 'CategoriesLayout', $CategoriesLayout);
        }
        }
    }
    
  • That is a good idea @peregrine!

    Should probably just add the data to the form so it will auto-populate. I forgot to unpack the layout user meta for some reason as well. My modified version is below:

    public function UserModel_AfterGetSession_Handler($Sender) {
      $User = $Sender->EventArguments['User'];
      // override the default controller route temporarily if it has been set
      $Controller = $this->GetUserMeta($User->UserID, 'DefaultController', FALSE, TRUE);
      if($Controller) {
        Gdn::Router()->SetRoute('DefaultController', $Controller, 'Internal', FALSE);
      }
      // override the default layout temporarily
      $DiscussionsLayout = $this->GetUserMeta($User->UserID, 'DiscussionsLayout', C('Vanilla.Discussions.Layout', 'modern'), TRUE);
      $CategoriesLayout = $this->GetUserMeta($User->UserID, 'CategoriesLayout', C('Vanilla.Categories.Layout', 'modern'), TRUE);
      SaveToConfig('Vanilla.Discussions.Layout', $DiscussionsLayout, array('Save' => FALSE));
      SaveToConfig('Vanilla.Categories.Layout', $CategoriesLayout, array('Save' => FALSE));
    }
    
    public function ProfileController_EditMyAccountAfter_Handler($Sender) {
      $User = $Sender->User;
    
      // Load their current settings
      $Controller = $this->GetUserMeta($User->UserID, 'DefaultController', FALSE, TRUE);
      $DiscussionsLayout = $this->GetUserMeta($User->UserID, 'DiscussionsLayout', FALSE, TRUE);
      $CategoriesLayout = $this->GetUserMeta($User->UserID, 'CategoriesLayout', FALSE, TRUE);
    
      // Save the settings to the form
      $Sender->Form->SetValue('DefaultController', $Controller);
      $Sender->Form->SetValue('DiscussionsLayout', $DiscussionsLayout);
      $Sender->Form->SetValue('CategoriesLayout', $CategoriesLayout);
    
      $ControllerOptions = array(
          'discussions' => 'Discussion List',
          'categories' => 'Category List'
      );
      $LayoutOptions = array(
          'modern' => T('Modern non-table-based layout'),
          'table' => T('Classic table layout used by traditional forums')
      );
      echo '<li class="Homepage">';
      echo $Sender->Form->Label('Homepage View', 'DefaultController');
      echo $Sender->Form->DropDown('DefaultController', $ControllerOptions, array('IncludeNull' => TRUE));
      echo $Sender->Form->Label('Discussions View', 'DiscussionsLayout');
      echo $Sender->Form->DropDown('DiscussionsLayout', $LayoutOptions, array('IncludeNull' => TRUE));
      $LayoutOptions['mixed'] = T('All categories listed with a selection of 5 recent discussions under each');
      echo $Sender->Form->Label('Categories View', 'CategoriesLayout');
      echo $Sender->Form->DropDown('CategoriesLayout', $LayoutOptions, array('IncludeNull' => TRUE));
      echo '</li>';
    }
    
    public function UserModel_AfterSave_Handler($Sender) {
      $FormValues = $Sender->EventArguments['FormPostValues'];
      $UserID = val('UserID', $FormValues, 0);
      // Require valid user ID
      if(!is_numeric($UserID) || $UserID <= 0) {
        return;
      }
      $DefaultController = val('DefaultController', $FormValues, FALSE);
      if($DefaultController) {
        $this->SetUserMeta($UserID, 'DefaultController', $DefaultController);
      }
      $DiscussionsLayout = val('DiscussionsLayout', $FormValues, FALSE);
      if($DiscussionsLayout) {
        $this->SetUserMeta($UserID, 'DiscussionsLayout', $DiscussionsLayout);
      }
      $CategoriesLayout = val('CategoriesLayout', $FormValues, FALSE);
      if($CategoriesLayout) {
        $this->SetUserMeta($UserID, 'CateogoriesLayout', $CategoriesLayout);
      }
    }
    

    The key differences are I set the value on the form to what I got from the user table. I also passed in TRUE in the GetUserMeta() method so it automatically unfolds the data rather than return an array.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • peregrineperegrine MVP
    edited June 2014

    you could make another historical change to hg's most recent version and it will fix your dashboard issue :)

    and when you name it either name it default.php or class.CustomHomepage.Plugin.php

     public function UserModel_AfterGetSession_Handler($Sender) {
            $qs = $_SERVER['QUERY_STRING'];
            if (preg_match("#dashboard/settings/#",$qs)) {
            return;
            }
            $User = $Sender->EventArguments['User'];
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited June 2014

    That is a good idea @peregrine!

    Should probably just add the data to the form so it will auto-populate. I forgot to unpack the layout user meta for some reason as well.

    I did it the hard way. to heck with using the already builtin stuff >:) just kidding.

    you are the master @‌hgtonight ! very nice shortcuts.
    good testing and experimenting and great idea for a plugin @DoyceT‌

    also after complete ironing out, it should be added to add-ons - it is a very nice plugin with features unlike other plugins with good examples and efficiently coded by hg.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • hgtonighthgtonight MVP
    edited June 2014

    Edit, looks like I cross-posted. So here is one final suggestion, only modify the routes and layout if we are on the appropriate controller!

    public function UserModel_AfterGetSession_Handler($Sender) {
      $Request = Gdn::Request();
      if($Request->Path() == '') {
        $User = $Sender->EventArguments['User'];
        // override the default controller route temporarily if it has been set
        $Controller = $this->GetUserMeta($User->UserID, 'DefaultController', FALSE, TRUE);
        if($Controller) {
          Gdn::Router()->SetRoute('DefaultController', $Controller, 'Internal', FALSE);
        }
      }
    }
    
    public function Gdn_Dispatcher_AfterControllerCreate_Handler($Sender) {
      $User = Gdn::Session()->User;
      $Controller = $Sender->EventArguments['Controller'];
    
      // override the default layout temporarily if applicable
      switch($Controller->ControllerName) {
        case 'discussionscontroller':
          $DiscussionsLayout = $this->GetUserMeta($User->UserID, 'DiscussionsLayout', C('Vanilla.Discussions.Layout', NULL), TRUE);
          SaveToConfig('Vanilla.Discussions.Layout', $DiscussionsLayout, array('Save' => FALSE));
          break;
        case 'categoriescontroller':
          $CategoriesLayout = $this->GetUserMeta($User->UserID, 'CategoriesLayout', C('Vanilla.Categories.Layout', NULL), TRUE);
          SaveToConfig('Vanilla.Categories.Layout', $CategoriesLayout, array('Save' => FALSE));
          break;
      }
    }
    
    public function ProfileController_EditMyAccountAfter_Handler($Sender) {
      $User = $Sender->User;
      // Load their current settings
      $Controller = $this->GetUserMeta($User->UserID, 'DefaultController', FALSE, TRUE);
      $DiscussionsLayout = $this->GetUserMeta($User->UserID, 'DiscussionsLayout', FALSE, TRUE);
      $CategoriesLayout = $this->GetUserMeta($User->UserID, 'CategoriesLayout', FALSE, TRUE);
      // Save the settings to the form
      $Sender->Form->SetValue('DefaultController', $Controller);
      $Sender->Form->SetValue('DiscussionsLayout', $DiscussionsLayout);
      $Sender->Form->SetValue('CategoriesLayout', $CategoriesLayout);
      $ControllerOptions = array(
          'discussions' => 'Discussion List',
          'categories' => 'Category List'
      );
      $LayoutOptions = array(
          'modern' => T('Modern non-table-based layout'),
          'table' => T('Classic table layout used by traditional forums')
      );
      echo '<li class="Homepage">';
      echo $Sender->Form->Label('Homepage View', 'DefaultController');
      echo $Sender->Form->DropDown('DefaultController', $ControllerOptions, array('IncludeNull' => TRUE));
      echo $Sender->Form->Label('Discussions View', 'DiscussionsLayout');
      echo $Sender->Form->DropDown('DiscussionsLayout', $LayoutOptions, array('IncludeNull' => TRUE));
      $LayoutOptions['mixed'] = T('All categories listed with a selection of 5 recent discussions under each');
      echo $Sender->Form->Label('Categories View', 'CategoriesLayout');
      echo $Sender->Form->DropDown('CategoriesLayout', $LayoutOptions, array('IncludeNull' => TRUE));
      echo '</li>';
    }
    
    public function UserModel_AfterSave_Handler($Sender) {
      $FormValues = $Sender->EventArguments['FormPostValues'];
      $UserID = val('UserID', $FormValues, 0);
      // Require valid user ID
      if(!is_numeric($UserID) || $UserID <= 0) {
        return;
      }
      $DefaultController = val('DefaultController', $FormValues, FALSE);
      if($DefaultController) {
        $this->SetUserMeta($UserID, 'DefaultController', $DefaultController);
      }
      $DiscussionsLayout = val('DiscussionsLayout', $FormValues, FALSE);
      if($DiscussionsLayout) {
        $this->SetUserMeta($UserID, 'DiscussionsLayout', $DiscussionsLayout);
      }
      $CategoriesLayout = val('CategoriesLayout', $FormValues, FALSE);
      if($CategoriesLayout) {
        $this->SetUserMeta($UserID, 'CategoriesLayout', $CategoriesLayout);
      }
    }
    

    This version will only load the user preferences if we are on the appropriate controller. It also will only change the default controller if the request path is empty. This gets rid of some edges cases I didn't think about in regards to changing the system wide homepage options.

    EDIT - Looks like I cross-posted again. LOL :D

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • DoyceTDoyceT ✭✭✭

    I take some small pride in coming up with a topic that has the two of you interested enough to keep cross-posting. :)

  • @peregrine said:
    also after complete ironing out, it should be added to add-ons - it is a very nice plugin with features unlike other plugins with good examples and efficiently coded by hg.

    I think this is a pretty good example of collaborative work: shows the initial version, the benefit of multiple eyes and different ideas.

    All we need is a sweet icon from @vrijvlinder‌ :wink:

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • DoyceTDoyceT ✭✭✭

    Thanks, @hgtonight‌ - I'm going to put your latest into my version of the plugin, but before I do, would it make sense to swap in @peregrine‌'s lines from this post - http://vanillaforums.org/discussion/comment/210227/#Comment_210227 - for lines 1 to 4 in your latest example?

  • @DoyceT‌ @peregrine and I came up with different solutions to solve that problem. My latest example overrides the layout configs when on the appropriate controller. This means it won't (or shouldn't ; ) interfere with the dashboard at all.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • DoyceTDoyceT ✭✭✭

    That's what I was hoping you'd say (since it means I half-understood the code). :)

  • DoyceTDoyceT ✭✭✭
    edited June 2014

    Alright, just for posterity, here's the final version I ended up with, all of which seems to be working exactly as advertised.

    I have a .zip file of the plugin directory (including vrijvlinder's excellent icon), so now I suppose I just need to figure out how to add a plugin to the directory.

    <?php if (!defined('APPLICATION')) exit(); ?>
    
    <?php
    $PluginInfo['CustomHomepage'] = array(
       'Name' => 'Custom Homepage',
       'Description' => 'This plugin allows users to set their own choices for which homepage they will see when they connect to the forum.',
       'Version' => '0.2',
       'Author' => "Doyce Testerman - but really peregrine and hgtonight - plus vrijvlinder for the awesome icon.",
       'AuthorEmail' => 'doyce.testerman@gmail.com',
       'AuthorUrl' => 'http://vanillaforums.org/discussion/27138/any-to-give-users-their-own-selection-of-homepage-layout'
    );
    ?>
    
    <?php
    class CustomHomepagePlugin extends Gdn_Plugin {
    
    public function UserModel_AfterGetSession_Handler($Sender) {
        $Request = Gdn::Request();
       if($Request->Path() == '') {
       $User = $Sender->EventArguments['User'];
    
    // override the default controller route temporarily if it has been set
    
       $Controller = $this->GetUserMeta($User->UserID, 'DefaultController', FALSE, TRUE);
       if($Controller) {
       Gdn::Router()->SetRoute('DefaultController', $Controller, 'Internal', FALSE);
       }
     }
    }
    
    public function Gdn_Dispatcher_AfterControllerCreate_Handler($Sender) {
       $User = Gdn::Session()->User;
       $Controller = $Sender->EventArguments['Controller'];
    
    // override the default layout temporarily if applicable
    
       switch($Controller->ControllerName) {
       case 'discussionscontroller':
       $DiscussionsLayout = $this->GetUserMeta($User->UserID, 'DiscussionsLayout', C('Vanilla.Discussions.Layout', NULL), TRUE);
       SaveToConfig('Vanilla.Discussions.Layout', $DiscussionsLayout, array('Save' => FALSE));
       break;
       case 'categoriescontroller':
       $CategoriesLayout = $this->GetUserMeta($User->UserID, 'CategoriesLayout', C('Vanilla.Categories.Layout', NULL), TRUE);
       SaveToConfig('Vanilla.Categories.Layout', $CategoriesLayout, array('Save' => FALSE));
       break;
       }
    }
    
    public function ProfileController_EditMyAccountAfter_Handler($Sender) {
       $User = $Sender->User;
    
    // Load their current settings
    
       $Controller = $this->GetUserMeta($User->UserID, 'DefaultController', FALSE, TRUE);
       $DiscussionsLayout = $this->GetUserMeta($User->UserID, 'DiscussionsLayout', FALSE, TRUE);
       $CategoriesLayout = $this->GetUserMeta($User->UserID, 'CategoriesLayout', FALSE, TRUE);
    
    // Save the settings to the form
    
       $Sender->Form->SetValue('DefaultController', $Controller);
       $Sender->Form->SetValue('DiscussionsLayout', $DiscussionsLayout);
       $Sender->Form->SetValue('CategoriesLayout', $CategoriesLayout);
       $ControllerOptions = array(
       'discussions' => 'Discussion List',
       'categories' => 'Category List'
       );
       $LayoutOptions = array(
       'modern' => T('Modern non-table-based layout'),
       'table' => T('Classic table layout used by traditional forums')
       );
       echo '<li class="Homepage">';
       echo $Sender->Form->Label('Homepage View', 'DefaultController');
       echo $Sender->Form->DropDown('DefaultController', $ControllerOptions, array('IncludeNull' => TRUE));
       echo $Sender->Form->Label('Discussions View', 'DiscussionsLayout');
       echo $Sender->Form->DropDown('DiscussionsLayout', $LayoutOptions, array('IncludeNull' => TRUE));
       $LayoutOptions['mixed'] = T('All categories listed with a selection of 5 recent discussions under each');
       echo $Sender->Form->Label('Categories View', 'CategoriesLayout');
       echo $Sender->Form->DropDown('CategoriesLayout', $LayoutOptions, array('IncludeNull' => TRUE));
       echo '</li>';
    }
    
    public function UserModel_AfterSave_Handler($Sender) {
       $FormValues = $Sender->EventArguments['FormPostValues'];
       $UserID = val('UserID', $FormValues, 0);
    
    // Require valid user ID
    
       if(!is_numeric($UserID) || $UserID <= 0) {
       return;
       }
       $DefaultController = val('DefaultController', $FormValues, FALSE);
       if($DefaultController) {
       $this->SetUserMeta($UserID, 'DefaultController', $DefaultController);
       }
       $DiscussionsLayout = val('DiscussionsLayout', $FormValues, FALSE);
       if($DiscussionsLayout) {
       $this->SetUserMeta($UserID, 'DiscussionsLayout', $DiscussionsLayout);
       }
       $CategoriesLayout = val('CategoriesLayout', $FormValues, FALSE);
       if($CategoriesLayout) {
       $this->SetUserMeta($UserID, 'CategoriesLayout', $CategoriesLayout);
       }
       }
    }
    
  • I suggest you use the same name for the folder and the plugin

    CustomHomepage on all so it won't have problems disabling.

    Add this before the last }

    public function OnDisable() {
          return TRUE;
       }
    
  • call the icon icon.png in your zip.

    make sure your folder is called CustomHomepage'

    and you probably just want to call the file default.php

    and zip it and upload it.

    then add some screenshots and add the icon to the page.

    that's it.

    you may need to change the author to your screenname if it doesn't let you upload.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • DoyceTDoyceT ✭✭✭

    Thanks!

    I'm trying to upload the .zip file via http://vanillaforums.org/addon/add? (zip contains the .php file and the .png icon), but I'm getting an error message

    This page is only for adding Vanilla 2 addons. If you want to add a Vanilla 1 addon click here.

    So I'm going to leave it for a bit and see if I can figure out what I'm doing wrong. Need to go pick up the dog.

    I attached the zip in case one of you can spot some obvious mistake I'm making.

Sign In or Register to comment.