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.

Custom Registration help

Hello Vanilla users. I've been trying to add this 1 extra field to my registration field but I can't seem to have actually write it to my database.
Must say I'm quite new at using PHP and doesn't seem like the API is explained very well for Vanilla or I've been unable to find the proper site.
Anyways based on this:http://vanillaforums.org/discussion/15120/custom-registration-fields

I've tried to edit my \applications\dashboard\views\entry\registerapproval.php

<li>
     <?php
        echo $this->Form->Label('Main Warframe', 'main_warframe');
        echo $this->Form->DropDown('main_warframe', array('Ash', 'Banshee', 'Ember', 'Excalibur', 'Frost', 'Loki', 'Mag', 'Nova', 'Nyx', 'Rhino', 'Saryn', 'Trinity', 'Vauban', 'Volt'), array('default' => 'Ash'));
     ?>
</li>

And I've edited \applications\dashboard\models\class.usermodel.php

To following (Under InsertForApproval() )

$Fields['Email'] = $Email;

$Fields['Roles'] = (array)$RoleIDs;
$Fields['main_warframe'] = $_POST['main_warframe'];

Even though in my database it keeps getting set as 'NULL'

I probably have done something horrible wrong question is what. I simply have 'NULL' idea what the heck I've done wrong.

Anyone know what to do? Please share!

Comments

  • which version of vanilla?

  • peregrineperegrine MVP
    edited July 2013

    I've tried to edit my \applications\dashboard\views\entry\registerapproval.php

    don't edit the core files

    create a plugin - its not too hard and you will be ahead of the game, so to speak...

    don't edit my \applications\dashboard\views\entry\registerapproval.php
    copy it to a views folder of a plugin.

    create a new plugin called WarfareRegistration

    look at this so you understand a bit of concept:

    http://vanillaforums.org/discussion/20359/annotated-plugin-how-to-write-a-plugin-for-how-to-set-guest-to-view-title-only-and-not-content

    also look at example plugin in documentation page

    in
    plugins/WarfareRegistration/default.php

    add this to it e.g. to add a Warframe Column in user table.

        class WarfareRegistration extends Gdn_Plugin
        {
            public function Setup()
            {
                $this->Structure();
            }
    
            public function Structure()
            {
    
                    Gdn::Structure()
                    ->Table('User')
                    ->Column('Warframe', 'varchar(50)', NULL)
                    ->Set();
            }
    

    //anytime you add a structure or change it, you must enable and disable plugin to create any new columns in database.

    WarFareRegistration/views\entry\registerapproval.php

    and add something like this:

                 echo $this->Form->Label('Warframe', 'Warframe');
                             echo $this->Form->DropDown('Warframe', array('Ash', 'Banshee', 'Ember', 'Excalibur', 'Frost', 'Loki', 'Mag', 'Nova', 'Nyx', 'Rhino', 'Saryn', 'Trinity', 'Vauban', 'Volt'), array('default' => 'Ash'));    
    

    then you will need some form validation in default.php
    and some events depending on where you want to show the Warframe (e.g. profile or discussions) - see symboledit

    which you can see in Documentation or in plugins below

    and experiment and look at the wiki for more help if you get stumped.

    then look at original botstop or first last names plugins for more details.

    I think in 2.1 and 2.2 - there may be an even an easier way, but I haven't tried it.

    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 July 2013

    there may be a syntax error or it might work - but this should give you a better start.

    anyone else feel free to improve on it.

    add to

        WarFareRegistration/views\entry\registerapproval.php
    
         </li>
              <li class="Gender">
                 <?php
                  echo $this->Form->Label('Warframe', 'Warframe');
            echo $this->Form->DropDown('Warframe', array('Ash' => "Ash", 'Banshee'=>'Banshee', 'Ember'=>'Ember', 'Excalibur'=>'Excalibur', 'Frost'=>'Frost', 'Loki'=>'Loki', 'Mag'=>'Mag', 'Nova'=>'Nova', 'Nyx'=>'Nyx', 'Rhino'=> 'Rhino', 'Saryn'=>'Saryn', 'Trinity'=> 'Trinity', 'Vauban'=>'Vauban', 'Volt'=>'Volt'), array('default' => 'Ash')); 
              ?>
             </li>
              <li>
    
    in default.php 
    
        <?php if (!defined('APPLICATION')) exit();
    
    
        // Define the plugin:
        $PluginInfo['WarfareRegistration'] = array(
           'Name' => 'Warfare Registration',
           'Description' => 'Add war frame field to registrationapproval',
           'Version' => '1',
             'MobileFriendly' => TRUE,
    
        );
    
        class WarfarePlugin extends Gdn_Plugin {
    
         public function Setup(){
        $this->Structure();
        }
    
        public function Structure() {
        Gdn::Structure()
        ->Table('User')
        ->Column('Warframe', 'varchar(50)', NULL)
        ->Set();
        }
    
    
     public function EntryController_Render_Before($Sender,$Args){
    
        //borrowed part of the if conditional from botstop plugin.      
    
    if(strcasecmp($Sender->RequestMethod,'register')==0)
                {
                    if(strcasecmp($Sender->View,'registerthanks')!=0 && strcasecmp($Sender->View,'registerclosed')!=0)
                    {
                        $Sender->View = $this->GetView( 'registerapproval.php');
                    }
                }
            }
    
        public function UserModel_BeforeRegister_Handler($Sender){
                $test = $Sender->EventArguments['User']['Warframe'];
    
        // you probably don't need this because you already have default set, but if you didn't
        if  ($test == "") {
                $Sender->Validation->AddValidationResult('Warframe',T('Warframe Needed'));
                $Sender->EventArguments['Valid'] = FALSE;
            }
    
        } 
    
     }
    

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

  • Wow thanks a bunch! Also using 2.0.18

  • Sadly all I get now when hitting 'apply for membership' is BONK error.

  • QvintusQvintus New
    edited July 2013

    Done a few changed based on what I could see in RegistrationRoles Plugin (makes it show on registration form but still doesn't add anything)

    Since I have no idea how to put it up nice a neat like you did I gotta link to a zip file.
    3dn.dk/dl/WarframeRegistration.zip

    Also since I am unable to find any API, anyone can guide me to where it is?
    Or will I simply have to try find it in the Forum files?

  • QvintusQvintus New
    edited July 2013

    NVM it actually works now, will try to make it show in profile based on what you have showed me. Again thx for the help!

Sign In or Register to comment.