Scandal
Well-known member
Below is a sample of a class extension (XF\Entity\Forum).
The issue: I need during a post of a thread, to return an error message (sc_phrase). I mean after click the "Post thread" button.
But the system is returning instead of the sc_phrase, a "No permission" xF2 message.
I need to return the correct message (sc_phrase phrase).
Can you see something wrong on the code?
I mean logical errors, no xF2 normalization issues (the code is a sample of the original).
It seems that the return false is working, but not the $error.
Code:
class Forum extends XFCP_Forum
{
public function canCreateThread(&$error = null)
{
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$error = \XF::phraseDeferred('sc_myphrase');
return false;
}
$main_reply = parent::canCreateThread($error);
return $main_reply;
}
}
The issue: I need during a post of a thread, to return an error message (sc_phrase). I mean after click the "Post thread" button.
But the system is returning instead of the sc_phrase, a "No permission" xF2 message.
I need to return the correct message (sc_phrase phrase).
Can you see something wrong on the code?
I mean logical errors, no xF2 normalization issues (the code is a sample of the original).
It seems that the return false is working, but not the $error.