• EDIT: Fixed code.

    This affects PDb Version 1.6.2.5.

    Hidden fields with dynamic default values are not preserved when editing records (pdb_record shortcode), and the code does not do what the comments in it say. Take a look at this:

    if ($field->form_element === 'hidden') {
    
          /*
           * use the dynamic value if no value has been set
           */
          if (in_array($this->module, array('signup', 'record', 'retrieve'))) {
            if (Participants_Db::is_dynamic_value($field->default)) {
              $value = $this->get_dynamic_value($field->default);
            }

    There is no check to see if the $value already contains something, and thus fields such as post->post_name and post->post_title are overwritten every time when trying to edit records (pdb_record).

    Line 847 in PDb_Shortcode.class.php should be changed from:

    $value = $this->get_dynamic_value($field->default);

    to

    $value = !isset($this->participant_values[$field->name]) ? $this->get_dynamic_value($field->default) : $value;

    This was a fairly recent change, as it broke on my site that makes use of a hidden field upon signup with the default value of post->post_title to distinguish different signup pages. I’ve verified that the change works and that other hidden fields such as the session_hash field are still properly updated every time.

    Note that this cannot be fixed merely with a custom template, as the function is called through the print_form_head() function, so this needs to be fixed in PDb itself.

    Thanks!

    https://wordpress.org/plugins/participants-database/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Bug Report: hidden fields reset in _set_field_value in PDb_Shortcode.class.php’ is closed to new replies.