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.

New Plugin



  • edited June 2016

    I'll upload by update 'NewReview' plugin code in a bit.

    @rbrahmson I am not looking to display it in the discussion meta area. I want to copy the contents of the fields (FieldA, FieldB, etc.) to the body box.

    When the review is posted, the post looks like so:

    Field A:
    Field B:
    Field C:
    Then below that, the user writes the full review.
    //Last entry in the review is a yes or no question as follows:
    Do you recommend this product? Field D

  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    You mean when the discussion is displayed for commenting as opposed to the discussion list? Well, that too can be done via hooks, and at least one of the previously mentioned plugins does that.

  • I'll look again.

    I was trying to wrap the fields (FieldA, FieldB, etc.) followed by a line break between each field to the BodyBox.

  • Give me a few hours. I think I'm close. Thanks for pointing me in the right direction.

  • Couldn't do it. I thought I would be able to pass the TextBox inputs to the BodyBox() argument and have it post.

    It did not work.

  • R_JR_J Ex-Fanboy Munich Admin

    I'm not really sure if I understand what you are trying to do. If you try to change what is in the BodyBox before post, I would assume you try to change the body of the discussion before it is saved.
    Remember, that BodyBox is only some nearly arbitrary name for the form element in which the discussions body is encapsuled. We are speaking of the visualization layer only.
    If you try to change the form before it is posted so that the changed values will be posted, you would have to change the form with JavaScript.
    PHP presents first the empty form and after you press post sends the current form values to the server processes them and sends back the result of the process.

    If you want to change what is saved in Vanilla you can certainly do that, but you will not be able to do so by hooking some events fired in views. You have to hook into the model. Try (in a test environment!) this few lines:

    public function discussionModel_beforeSaveDiscussion_handler($sender, $args) {

    Before a discussion is saved (only discussion, not comments), all the available EventArguments are printed to screen and then the processing stops. If you omit the die;, the result would not be printed to screen since the result of the post process would reload the page. That's why I used it here.

    You see that you have access to all values of your form and you can change them as you like before they are saved:

    public function discussionModel_beforeSaveDiscussion_handler($sender, $args) {
        $args['FormPostValues']['Body'] = $args['FormPostValues']['FieldA'].': '.$args['FormPostValues']['Body']; 

    (All code untested)

    But honestly: I've completely lost track in what you try to do and so each line of code might be either helpful or not related at all. It would be very helpful if you could provide some code.

  • @R_J I want to take the fields that are in the 'HowToFormValidate' plugin and put them all in the body of the discussion when the post is made.

  • @R_J Please see my github. Two files have been edited that show what I am trying to accomplish:

    post.php class.newreview.plugin.php

    You can run the plugin to see what I am going for.

Sign In or Register to comment.