Hi there,

I'm currently developing the extension which help to add google reCaptcha to symphony. but i got issue when i tried to add event filter with the extension code.

Basically i need to know:

  1. How to get post data value to event filter.

  2. And how to stop the event executing when filter is failed.

2nd question mean.. I have created an event filter which is working, but even if it fails, the event is executing and data is being added to the section. I need to ensure that if the filter fails, the entry is not created

you can check the new code from my git repository.

Regarding event filters: If you want to prevent saving, you must use the EventPreSaveFilter delegate — you did that, as far as I have seen. But your custom function must populate the $context['messages'] array, e.g.:

$context['messages'][] = array(
    ($success === false) ? __('You are not authorised to perform this action.') : null

If the second value is false, the event will terminate. If it's true, data will be saved.

Post data will be in $_POST['fields'], of couse. But looking at the code in the Symphony core (processPreSaveFilters in class.event.section):

        'fields' => &$fields,
        'event' => &$this,
        'messages' => &$this->filter_results,
        'post_values' => &$post_values,
        'entry_id' => $entry_id

it seems that you can get (and even manipulate) the data using $context['post_values'].

For debugging the delegate stuff, you can always var_dump the $context in order to see which data is available at this point.

Hi michael-e,

Thanks, with your help now i'm able to prevent saving the entry.

But i'm still having a issue with get the POST data to function. please check my below function code and it's very helpful if you can tell me what is the the issue.

I got a hidden field called 'recaptcha' in the front-end form.

          public function processEventData( $context ) {

                     //this also not working
         //$values = $context['recaptcha']; 

                    $values = $context['post_values'];
        $value = $values->recaptcha;

        if($value == 1){
            $status = true;
            $status = false;

        $context['messages'][] = array('recaptcha', $status, (!$status 
                    ? 'invalid.' : NULL));

Have you tried var_dump($context) inside your function? You should be able to see the whole thingie.

I would try:

  • var_dump($context)
  • var_dump($context['post_values']) — is it XML? Then it may be better to try "fields":
  • var_dump($context['fields']) — is this an array with the desired element(s)?
  • if nothing helps: var_dump($_POST['fields'])

Sorry, I don't know that stuff by heart, so the above is what I would do.

Thanks a lot. all good now. appreciate it.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details