Skip to:
Content
Pages
Categories
Search
Top
Bottom

Create a feedback form using buddypress messaging functionality


  • Mitesh Patel
    Participant

    @mitesh-patel

    I am developing locally using MAMP, with wp 3.5, bp 1.6.4 with sitewide bbPress.

    I want to use the buddypress messaging as feedback form (for logged in users only). I will create users called question, suggestion, feedback etc. which will receive these messages from users.

    The form will contain a html select box dropdown (with options question, suggestion, feedback etc.) instead of recipient input from bp standard message form, rest being the same. Users will select the type of feedback from the select box, input the subject and content, and submit the message.

    My problem is, how to ‘tell’ the standard buddypress message form to send the message to the selected recipient from the select box?

    I did the following.

    created a template, with form code copied from message.php (from bp-default > members > single > messages), changing recipient input to html select with options (suggestion, feedback etc.), keeping the id, class etc. of the previous input box itself.

    created a blank page and applied the template.

    Result:
    The template renders fine, but the message is not sent, nor are errors rendered (eg. if I leave both subject and content empty).

    Also, the page redirects to the logged in user’s inbox, and I need to change this to a custom redirect. Please advise how to do this, as well.

    Also let me know if I should remove any redundant code.

    Edit: php code removed as it got stripped out! Sorry.

    Edit2: I thought of testing the form without any change (verbatim compose.php code with default text box for recipient name) but that doesn’t work either. It seems, it needs to be wrapped around the by buddypress code, but I can’t pinpoint which function must I include so the default text-box works.

Viewing 4 replies - 1 through 4 (of 4 total)

  • Mitesh Patel
    Participant

    @mitesh-patel

    OK, now I have got the form working on a stand-alone page with strategy described above with one change.

    I changed the form’s action atribute to point to the original action (buddypress message compose page).

    now the form posts fine, but redirects to the user inbox, irrespective if the form was submitted successfully or with error. The success and error messages are rendered correctly, but this is not logically correct behavior.

    The form page should redirect to itself. Please advise, how can I do it.

    `/buddypress/bp-messages/bp-messages-screens.php:76`

    As you can see there – no way. Try to hook into `bp_core_redirect()` OR write your own handler foe sending messages, with use of `messages_new_message()`


    Mitesh Patel
    Participant

    @mitesh-patel

    Thank you @slaffik for your response. I figured that much, and I posted another thread subsequently asking how to hook into bp_core_redirect(). I was suggested that bp_core_redirect() in turn calls wp_safe_redirect, which could be hooked into, but I am clueless how? Sorry, not a programmer. Can you point me to an example I could analyse?

    Secondly, Can I override the messages_screen_compose function from bp-messages-screens.php by writing an entirely new function by same name in my theme’s function.php (with my custom redirects with if-else, which seems very easy and non-intrusive), and doing some remove_action, add_action magic, so to speak? Writing the new function is easy, but how to implement/insert it so that it works is a mystery for me.


    Mitesh Patel
    Participant

    @mitesh-patel

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Create a feedback form using buddypress messaging functionality’ is closed to new replies.
Skip to toolbar