Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
859 views
in Q2A Core by
Normally, Name and Email is optional on Send Feedback Page.

But I want to do necessary and not null.

How can I do it?
Q2A version: 1.7.4

1 Answer

+1 vote
by

I hacked feedback form with this specification. My hacks are below.

qa-include/pages/feedback.php

else {
    if (empty($inmessage))
        $errors['message']=qa_lang('misc/feedback_empty');
    // Add [Start]
    if (empty($inname))
        $errors['name']=qa_lang('misc/feedback_empty');
    if (empty($inemail))
        $errors['email']=qa_lang('misc/feedback_empty');
    // Add [end]

    $qa_content['error']=@$pageerror;
    // Add [Start]
    if(isset($userprofile['name']) && !empty($userprofile['name']))
        $name = $userprofile['name'];
    else
        $name = @$useraccount['handle'];
    // Add [End]

    'type' => $feedbacksent ? 'static' : '',
    'label' => qa_lang_html('misc/feedback_name'),
    'tags' => 'name="name"',
    // Replace [Start]
    //'value' => qa_html(isset($inname) ? $inname : @$userprofile['name']),
    'value' => qa_html(isset($inname) ? $inname : $name),
    'error' => qa_html(@$errors['name']),
    // Replace [End]

    'tags' => 'name="email"',
    'value' => qa_html(isset($inemail) ? $inemail : qa_get_logged_in_email()),
    'note' => $feedbacksent ? null : qa_opt('email_privacy'),
    // Add [Start]
    'error' => qa_html(@$errors['email']),
    // Add [End]

qa-include/lang/qa-lang-misc.php

// Replace [Start]
//'feedback_email' => 'Your email: (optional)',
//'feedback_empty' => 'Please use this field to send some comments or suggestions',
//'feedback_message' => 'Your comments or suggestions for ^:',
//'feedback_name' => 'Your name: (optional)',
'feedback_email' => 'Your email:',
'feedback_empty' => 'Please use this field to send message',
'feedback_message' => 'Your message for ^:',
'feedback_name' => 'Your name:',
// Replace [End]

OR

qa-lang/custom/qa-lang-misc.php <= Create new custom language file

<?php
return array(
'feedback_email' => 'Your email:',
'feedback_empty' => 'Please use this field to send message',
'feedback_message' => 'Your message for ^:',
'feedback_name' => 'Your name:',
);

And also, you can deal with creating AND replacing with your new feedback form. In this case, you need experience of creating plugins.

  • Create new your page plugin
  • Copy program from qa-include/pages/feedback.php to your page in page plugin.
  • Modify according to the above procedure

by
Thank you very much and powerqa's theme is very nice.

Can I find anywhere this theme? :D
by
Seems codings have been changed for v1.7.5
...