0 users online. Create an account or sign in to join them.Users


(Just for reference if some other symphony users have the same need and as me are not very php.)

Scenario : a section has a unique field, (in the following case, it is an email). A front end form allow to create an new entry. If you need to update an existing entry (in the following case a security hash) instead of creating a new one, here is a custom event (thanks to @jonmifsud):

    public function load()
    require_once(TOOLKIT . '/class.entrymanager.php');

    if (isset($_POST['action']['subscription'])) {

        # create new hash
        $_POST['fields']['hash'] = sha1(serialize($_POST) . uniqid());

        # find existing entry ID
        $email = $_POST['fields']['email'];
        $existingentryid = Symphony::Database()->fetchVar("entry_id",0,"SELECT entry_id FROM sym_entries_data_XXX WHERE value = '$email'");

        if (isset($existingentryid)) {
            # Security check:
            # does other post values match existing entry? Here testing the birthdate
            $birthdate = $_POST['fields']['birthdate'];
            $EntryManager = new EntryManager(Symphony::Engine());
            $data = $EntryManager->fetch($existingentryid);
            $savedBirthdate = $data[0]->getData(YYY);
            $savedBirtdateFormated = date("Y-m-d", strtotime($savedBirthdate['value']));
            if ($birthdate == $savedBirtdateFormated) {
                # update
                $_POST['id'] = $existingentryid;

        return $this->__trigger();

XXX is the email field ID and YYY the birthdate field ID

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