/**
  * @param $operation
  * @param string $id
  */
 function save_add_edit_registration_builder($operation, $id = '')
 {
     if (isset($_POST['add_registration']) || isset($_POST['edit_registration'])) {
         $title = @esc_attr($_POST['rfb_title']);
         $structure = @stripslashes($_POST['rfb_structure']);
         $css = @stripslashes($_POST['rfb_css']);
         $success_registration = @stripslashes($_POST['rfb_success_registration']);
         // catch and save form generated errors in property @registration_builder_errors
         if (empty($_POST['rfb_title'])) {
             $this->registration_builder_errors = 'Title is empty';
         } elseif (empty($_POST['rfb_structure'])) {
             $this->registration_builder_errors = 'Registration Design is missing';
         }
         if (isset($this->registration_builder_errors)) {
             return;
         }
         if (isset($_POST['edit_registration']) && check_admin_referer('edit_registration_builder', '_wpnonce') && $operation == 'edit') {
             PROFILEPRESS_sql::sql_update_registration_builder($id, $title, $structure, $css, $success_registration, date('Y-m-d'));
             wp_redirect(add_query_arg('registration-edited', 'true'));
             exit;
         }
         if (isset($_POST['add_registration']) && check_admin_referer('add_registration_builder', '_wpnonce') && $operation == 'add') {
             $id = PROFILEPRESS_sql::sql_insert_registration_builder($title, $structure, $css, $success_registration, date('Y-m-d'));
             wp_redirect(sprintf('?page=%s&action=%s&registration=%s&_wpnonce=%s&registration-added=true', REGISTRATION_BUILDER_SETTINGS_PAGE_SLUG, 'edit', absint($id), wp_create_nonce('pp_edit_registration')));
             exit;
         }
     }
 }