Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
1.4k views
in Plugins by

I have been working lately on making a custom filed (" User Location")  mandatory  to fill up when registring  with the endless and kind help of user Sama55 ( That i thank very very much for his great support). 

Sama55 suggestion was

1) to create a plugin with function call : qa_register_plugin_module('filter', 'qa-profile-checker.php', 'qa_profile_checker', 'Profile Checker'); in qa-plugin.php.

2) then to use the following code under qa-profile-checker.php file.


<?php
require_once QA_INCLUDE_DIR.'qa-filter-basic.php';
class qa_profile_checker {
function filter_profile(&$profile, &$errors, $user, $oldprofile) {
$fb = new qa_filter_basic();
$userfields=qa_db_single_select(qa_db_userfields_selectspec());
foreach ($profile as $key => $value) {
// sanitize
$profile[$key] = qa_html($value);
foreach($userfields as $userfield) {
if ($userfield['fieldid']==$key) break;
}
switch ($userfield['title']) {
case 'location': // Location (Required)
$fb->validate_length($errors, $key, $value, 1, 100);
break;
      }
   }
 }

}

The solution worked great no problem until i switched from localhost ( windows) to live server (linux), a strange error message pop up when hitting sign up button:


Parse error: syntax error, unexpected 'QA_INCLUDE_DIR' (T_STRING) in /home/picassau/public_html/qa-plugin/q2a-location-required/qa-profile-checker.php on line 1  
 

How comes that in local it runs correctly but on server it does't not ? !!! Some one can help figuring out that mystery.

PS : Script Full credit to Sama55

Q2A version: 1.6.2

2 Answers

+4 votes
by
selected by
 
Best answer

I understood one seeming to be a cause.

My guess: Newline code of your source file is only CR. Change newline code in your file into CR+LF. Or, confirm text editor settings about newline.

by
YES SAMA it's working  !! you are a lifesaver !!! one should be very smart to figure out a solution to such a bug , thank you so so much
by
How can I make 'Full name' mandatory in registration page?
0 votes
by

Check qa-base.php if the specified folder is set correct:

define('QA_INCLUDE_DIR', QA_BASE_DIR.'qa-include/');

Also check if the file qa-filter-basic.php really exists.

Check also if the folder names are all correct.

by
All checks are positive, basically it wouldn't work on local server too if there syntax error. I have doubts that it's has to do with windows vs linux syntax or some  Web hosting manger setting
by
Try not including the file, maybe it works. (could be included twice...).

→ Shouldn't be the include within the CLASS body?

Put line: require_once QA_INCLUDE_DIR.'qa-filter-basic.php';
within class or function, then it should work.
by
hmm tried this also not working :( really strange problem, yesterday i recompiled my php version in vain too..
...