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.

Auto Post Application on Sign Up?

Hello All,

I have been browsing the web for a while to find an answer to this.

What I want to enable is maybe a complicated function however, it is quite important for our forums.

Basically when a new member wishes to apply for the forums I want to crete a custom application form which they have to fill in. Once they have filled in their application and submitted it I want it to be automatically posted on the forums under an applications section.
From this staff memebers could accept or decline this member based on the info provided.

Second is there a way to delete posts in a certain forum automatically after a period of time.
New "trialists" are on trial for one week, after which it is decided based on member feedback wether they can join the community. Is there a way that these posts would either auto delete or be marked for review after this time period of one week?

Thanks for any feedback you can give guys.

Regards,

Woft

Comments

  • peregrineperegrine MVP
    edited January 2014

    look into forms creation on the wiki and look in to kaspers api application as well as possibly lincoln's shwaipbot plugin

    and the signin event handler.

    and it is probably dependent on your version of vanilla that you use. what vanilla version are you using? you may need to 2.1b2 to fully implement easily with the api

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

  • I am using 2.0.18.10 at the moment. I will have a look into what you mentioned as well.

  • Hello,
    I tried reading through this but found it very confusing as we are unexperiencd with code. could you explain the process a little more?

  • edited January 2014

    It may be better to use the built-in approval registration method and modify it to fit your needs instead of creating new discussions for the registration applications.

    Add Pages to Vanilla with the Basic Pages app

  • I would also favor using the registration form.
    You would have to create a custom plugin. Look at some example plugins for that. It must have following form:

    <?php if (!defined('APPLICATION')) exit();
    
    $PluginInfo['YourPluginName'] = array(
       'Name' => 'Your Plugin Name',
       'Description' => 'This is the description shown in the dashboard',
       'Version' => '0.1',
       'Author' => 'You'
    );
    
    class YourPluginNamePlugin extends Gdn_Plugin {
    }
    // ?> THIS LINE IS NOT NEEDED! I just had to add it because otherwise the formatting was screwed :-/
    

    See examples in order to find out what fields are also possible for the $PluginInfo array.
    In its setup it must create the application form fields you would like to add:

    public function Setup() {
       Gdn::Structure()->Table('User')
          ->Column('WhateverYouWantToAsk', 'varchar(32)', TRUE)
          ->Column('SomethingOther', 'int', TRUE)
          ->Set(FALSE, FALSE);
    }
    

    Function Setup is called once when you activate your plugin. You would have to store your applicant infomration somewhere, it is info concerning the user so add the info to the user by extending the database to keep your information. All that is done with the above code.

    You want your applicants to be approved before they become members, right? So set your registration method to approval and override Vanillas register view (you might think in "templates" - in Vanilla they are called views).
    Overriding a view could be done by creating a file /plugins/YourPluginName/views/entry/registerapproval.php. Copy the content of the file /dashboard/views/entry/registerapproval.php to your new file and search for the following lines:

    <li>
    <?php
                echo $this->Form->Label('Why do you want to join?', 'DiscoveryText');
                echo $this->Form->TextBox('DiscoveryText', array('MultiLine' => TRUE, 'Wrap' => TRUE));
             ?>
    </li>
    

    Replace this with something you need. Could look anyway like this:

    <li>
    <?php
                echo $this->Form->Label('Give us info A', 'WhateverYouWantToAsk');
                echo $this->Form->TextBox('WhateverYouWantToAsk', array('Wrap' => TRUE));
             ?>
    </li>
    <li>
    <?php
                echo $this->Form->Label('Give us next info', 'SomethingOther');
                echo $this->Form->TextBox('SomethingOther', array('Wrap' => TRUE));
             ?>
    </li>
    

    See that I've used exactly the same names in the form as for the database columns? That's important! That way, all the field contents will be stored automagically! Great, isn't it?

    Now that your users have registered and filled out any info you want to get hold of, you will need a place where you can access this. Create a function public function SettingsController_YourPluginName_Create($Sender) {echo 'Hello World!';}. Whatever you do there could be accessed under www.example.com/settings/yourpluginname.
    So you want to see all user names and all your aditional fields of any user that has registered the last seven days? Maybe an Accept/Decline radio button and the number of accepts/declines? You would need an additional field in the database for that. Info could be stored as a serialized array there.
    You would need a form for that. In order to make sure that only staff members can access this site, you would have to create a special permission, but that would be easy.

    If I were used to creating forms I would suggest you some code, but I can't, sorry. From now it's up to you alone.

    My advice to you is that you start creating the plugin and make it as complete as you can. Whenever you have a specific question come back and there surely will be someone who can and will help you!

  • R_JR_J Admin
    edited January 2014

    :-( Overriding the view isn't as easy as I thought. You would have to create an event hook for that, but if you start working on the plugin, I could show you how to achieve that. Look at the RegistrationRole plugin for an example

  • WOW thank you for being so detailed, this definately helps. Will get back to you if i have problems...i am sure we will haha

  • I'm glad you take the challenge! :)

  • ok so i have implemented a new application form. I used Javascript to hide unwanted fields until they are clicked on in a radio button list.

    The problem is, i have written the radiobutton list in html and want to convert it over to php however, conventiaonal php doesn't seem to apply or this may be a misunderstanding on my part.

    i see the gender radio button list is called like this:

    
    <?php
        echo $this->Form->Label('Gender', 'Gender');
        echo $this->Form->RadioList('Gender', $this->GenderOptions, array('default' => 'm'))
        ?>
    
    

    however this provides no insight in how to create a radio button list.

    this is how i have created it in html:

    
    <?php 
      < FORM NAME =" myform " ACTION="" METHOD="POST"> Choose a game: < BR>
      < INPUT TYPE ="radio" NAME="input" VALUE="infestation" onClick="gameSelect(this.form)">Infestation< P>
      < INPUT TYPE ="radio" NAME="input" VALUE="leagueoflegends" onClick="gameSelect(this.form)">League of Legends< P>
      < INPUT TYPE ="radio" NAME="input" VALUE="nether" onClick="gameSelect(this.form)">Nether< P>
      < INPUT TYPE ="radio" NAME="input" VALUE="starconflict" onClick="gameSelect(this.form)">Star Conflict< P>
      < INPUT TYPE ="radio" NAME="input" VALUE="elderscrollsonline" onClick="gameSelect(this.form)">Scrolls< P>
    < /FORM>
    ?>
    
    

    how would i convert this over?

  • peregrineperegrine MVP
    edited February 2014

    you could put your info in an associative array or use enumerated options in your database field.

    you can search vanilla code for other examples of how radiolist is called from the code.
    e.g.
    applications/dashboard/views/settings/email.php:63:

    the info in class.form.php - might be helpful to look at. since you are calling that function.

     /**
        * Returns XHTML for an unordered list of radio button elements.
        *
        * @param string $FieldName The name of the field that is being displayed/posted with this input. 
        *    It should related directly to a field name in $this->_DataArray. ie. RoleID
        * @param mixed $DataSet The data to fill the options in the select list. Either an associative
        *    array or a database dataset.
        * @param array $Attributes An associative array of attributes for the list. Here is a list of
        *    "special" attributes and their default values:
        *
        *   Attribute   Options                        Default
        *   ------------------------------------------------------------------------
        *   ValueField  The name of the field in       'value'
        *               $DataSet that contains the
        *               option values.
        *   TextField   The name of the field in       'text'
        *               $DataSet that contains the
        *               option text.
        *   Value       A string or array of strings.  $this->_DataArray->$FieldName
        *   Default     The default value.             empty
        *   InlineErrors  Show inline error message?   TRUE
        *               Allows disabling per-dropdown
        *               for multi-fields like Date()
        *
        * @return string
        */
       public function RadioList($FieldName, $DataSet, $Attributes = 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.

  • Ok, so now I am forgetting about the auto post information on the forums, I simply want to save the custom fields I added to the register page so that on the applicants view I can see the information.

    I understand the DiscoveryText is shown in the applicants section of the dashboard with this code
    $this->EventArguments['User'] = $User; $this->FireEvent("ApplicantInfo"); echo '<blockquote>'.$User->DiscoveryText.'</blockquote>';
    I know how to add information to this page, but how do I get the information the applicant entered?

    is this is saved in the database, how do I add this application information into the database?

  • ok ignore this, i manually added the database column.

  • R_JR_J Admin

    Remember my post from some time ago:

    @R_J said:

    public function Setup() {
       Gdn::Structure()->Table('User')
          ->Column('WhateverYouWantToAsk', 'varchar(32)', TRUE)
          ->Column('SomethingOther', 'int', TRUE)
          ->Set(FALSE, FALSE);
    }
    

    You don't have to add columns manually ;)

  • would this go in the php file? i am creating the custom registration page by customising the stopbot plugin.
    and yes i forgot about this :disappointed:

  • woftwoft
    edited March 2014

    actually again i have answered my own question i think, i would add your code to the setup function of the plugin, so public function Setup() { SaveToConfig('Plugins.BotStop.Question', 'What is three plus three?'); SaveToConfig('Plugins.BotStop.Answer1', '6'); SaveToConfig('Plugins.BotStop.Answer2', 'six'); }
    becomes
    public function Setup() { SaveToConfig('Plugins.BotStop.Question', 'What is three plus three?'); SaveToConfig('Plugins.BotStop.Answer1', '6'); SaveToConfig('Plugins.BotStop.Answer2', 'six'); Gdn::Structure()->Table('User') ->Column('WhateverYouWantToAsk', 'varchar(32)', TRUE) ->Column('SomethingOther', 'int', TRUE) ->Set(FALSE, FALSE); }

    I would then have to disable and reenable to plugin for it to create the columns. what happens if the column is already in the database?

  • peregrineperegrine MVP
    edited March 2014

    the existence of column shouldn't matter.

    do yourself a favor and read the comments before each function in

    library/database/class.databasestructure.php

    you can also peruse the other files in that folder and you will probably learn some things.


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

  • R_JR_J Admin

    @Woft All your changes should go into your plugin. Normally there is no need to change any of the existing files and you shouldn't do it.

Sign In or Register to comment.