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.
Options

How to setup a profil settingspage with plugin

Hey vanilla community,

at the moment i'm struggling to get into the plugin development. i have a simple plugin in development which i can activate in the dashboard and i want to place a settings page for this plugin in the user profil. I added a new link in the sidemenu but now i have big problems with the settings page which i want to load when i follow the new added link.

I tryed it by using the ProfileController Create function, but i only getting a white page. Is there a tutorial or something else where i can learn how to setup this new page? I allready tryed to get this information from an other plugin, but it doesn't work :(

Best,
Verdemis

Comments

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    @Verdemis said:
    I tryed it by using the ProfileController Create function

    You're on the right track! I've struggled with that some time ago, too. This is the working solution I've ended with: https://github.com/R-J/ProfileVisitors/blob/master/class.profilevisitors.plugin.php

    Instead of using

       public function ProfileController_Visitors_Create($Sender) {
          // calls function Controller_Index
          $this->Dispatch($Sender);
       }
    
       public function Controller_Index($Sender) {
    

    you can directly use public function ProfileController_YourSlug_Create($Sender) {

    But if you already use it that way and you get a completely blank page, it is more probable that you have a syntax error in your code...

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    Sometimes when I've got no IDE at hand (I could recommend NetBeans) I use this web site for quick syntax checks: http://phpcodechecker.com/

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    ... and if you do not need a dedicated setting screen, you can also hook into the standard user settings:

    public function ProfileController_EditMyAccountAfter_Handler($Sender) {
       echo '<li>';
       echo $Sender->Form->Label('One small setting', 'YourFirstSetting');
       echo $Sender->Form->TextBox('YourFirstSetting', array('class' => 'InputBox SmallInput'));
       echo '</li>';
       echo '<li>';
       echo $Sender->Form->Label('Another one', 'YourSecondSetting');
       echo $Sender->Form->TextBox('YourSecondSetting', array('class' => 'InputBox SmallInput'));
       echo '</li>';
    }
    

    If your added information is in the database as additional columns in user table, that's all you've got to do!

  • Options

    Thank you R_J, i will check this when i'm at home. :D

Sign In or Register to comment.