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

I am inside the filter_answer() function and want to get the url of the question, how can i do that ? here is what i have done that has nothing to do with q2a functions and strongely does not work !!

function filter_answer(&$answer, &$errors, $question, $oldanswer) {

$url  = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] :  'https://'.$_SERVER["SERVER_NAME"];
$url .= $_SERVER["REQUEST_URI"];
 
echo " the current question url is" . $url

}
 

is there a more appropriate way to do it, using q2a core function to retreive the question url ?

Thank you 

Q2A version: latest

1 Answer

+1 vote
by
selected by
 
Best answer
I cannot check now. But I am quite sure that you can find the questionid (postid) in $question.

Try $question['postid']

Then you can have a short link:

$shortlink = 'www.yourdomain.com/'.$question['postid'];

 

Just try it and report back :)
Kai
by
thanks a lot ! it's working well !
...