Forum Replies Created

Viewing 15 replies - 1 through 15 (of 50 total)
  • Thread Starter natriya

    (@natriya)

    Thank you for your help 😊

    Thread Starter natriya

    (@natriya)

    Thansks you for your answers
    Indeed, the personal data retention was set . I just made them blank

    Is there a way to retreive back the data already deleted ?

    Thank you

    Thread Starter natriya

    (@natriya)

    Thank you @xnau 🙂

    Thread Starter natriya

    (@natriya)

    @xnau Hi and thank you for the update Version 1.7.8.11
    my issue is now resolved 🙂

    For information (if you would like to update the tutorial : https://xnau.com/matching-multiple-fields-with-csv-import-or-signup-submission/ ) here are the changes I made in PDb_Multifield_Match_Import

    public function __construct()
    {
    add_filter( ‘pdb-incoming_record_match’, array( $this, ‘check_for_match’ ), 10, 4 );
    add_filter( ‘pdb-process_form_matched_record’, array( $this, ‘provide_the_matched_id’ ) );
    }

    public function check_for_match( $match, $post, $duplicate_record_preference, $currently_importing_csv )
    {

    // prevent updating record from matching itself if we are avoiding duplicates
    $mask_id = ($duplicate_record_preference === ‘2’ and isset($post[‘id’])) ? $post[‘id’] : 0;

    $match_data = $this->match_data($post);

    $match_data[] = $mask_id;

    // set the match_id property to the result of our search
    $this->match_id = $this->check_db_for_match( $match_data );

    // return true if we have a match
    return $this->match_id !== false;
    }

    private function check_db_for_match( $match_data )
    {

    $query = ‘SELECT id FROM ‘ . Participants_Db::$participants_table . ‘ p WHERE ‘ . $this->where_clause(). ‘ AND p.id <> %s’;

    global $wpdb;
    $result = $wpdb->get_col( $wpdb->prepare( $query, $match_data ) );

    // add debugging to make sure the query and result is as expected
    if (WP_DEBUG) error_log(__METHOD__.’ query: ‘.$wpdb->last_query.’ result: ‘.print_r($result,1));

    // make sure there is only one match, then return the found ID
    if ( count( $result ) === 1 ) {
    return current( $result );
    }

    // no match or more than one match
    return false;
    }

    Thread Starter natriya

    (@natriya)

    @xnau Hence , do you think you could add then the duplicate record preference as a parameter passed to the filter ?

    Thread Starter natriya

    (@natriya)

    thank you 🙂

    Thread Starter natriya

    (@natriya)

    @xnau hi and thank you for your answer
    I’m really happy and relieve that we identified the cause of my issue 🙂

    In fact, as you said, I thought about checking for duplicates inside the filter when I have this condition $post[‘action’] === ‘update’ and with a $mask_id=$post[‘id’] (so that I would return $record_match=false if those condition are fullfiled). But I you pointed-out this doesn’t take into account the $duplicate_record_preference. That is why I suggested to pass $mask_id. However, passing $duplicate_record_preference is also fine. I would then in the filter code do :
    $mask_id = $duplicate_record_preference === ‘2’ ? $post[‘id’] : 0;
    And in the query, I would use the $mask_id the same way you use it to mask the id of the record being updated when checking for duplicates

    If I use the incoming $match value and check run a check only if it is false, I would stumble on the same issue that I wouldn’t be able to take into account the $duplicate_record_preference

    Hence I think that the ideal way to do this would be to pass either $duplicate_record_preference or $mask_id to the filter.
    I think it might be better to pass $duplicate_record_preference as you suggested, this way this value will be able to be use if necessary in the future and with this value it is easy to calculate $mask_id

    What do you think ?

    Thread Starter natriya

    (@natriya)

    Hi and thank you for your answer

    I just re-install the plugin and I still have the error
    When looking at the code, I was wondering if this error could be comming from this code here

    /*
    * if true, incoming record matches existing record or updated record matches another record
    */
    $record_match = $match_field_value !== ” && self::field_value_exists( $match_field_value, $match_field, $mask_id );

    /**
    * @since 1.6
    * the $record_match status variable is made available to a filter so a custom
    * record matching method can be implemented
    *
    * @param bool $record_match true if a matching record has been found
    * @param array $post the submitted post data
    */
    $record_match = self::apply_filters( ‘incoming_record_match’, $record_match, $post );

    When we have an update, the $mask_id makes the updating record set $record_match to false. But with the filter and the tutorial provided here https://xnau.com/matching-multiple-fields-with-csv-import-or-signup-submission/ there is no mask id applied in the code ran in the filter and $record_match turns back true for the record that is being edited.

    In my case, I’m using the filter provided in the tutorial. Moreover I noticed that it is working fine when I de-activate the code ran by the filter. That is why I was suggesting to pass the $mask_id to the filter also so that in the code, we would be able to use it the same way you are using it to make $record_match false when $mask_id matched the id of the record that is being recorded

    What do you think ?

    Thread Starter natriya

    (@natriya)

    hi yes that would be the idea.
    – At least those skipped (in my use case I have a file of 200 lines with 1 line skip and I don’t really know how to know easily and quickly which line it is),
    – if possible also those updated (that would help me identify which line already existed)
    – and ideally all state (meaning also those inserted – that would help me identify which line did not exist before)

    Thread Starter natriya

    (@natriya)

    Hi yes

    Thread Starter natriya

    (@natriya)

    Hi @xnau

    Thank you for your answer
    I just tried with the release number 1.7.8.10 and I still got the issue.

    Is there a configuration that I’m missing ?

    Thank you

    Thread Starter natriya

    (@natriya)

    Hi @xnau

    No.
    I did some more tests and I noticed that when using the built-in duplicate test process, there is no error when editing a record.
    However, when using a custom duplicate field with the tutorial provided here : https://xnau.com/matching-multiple-fields-with-csv-import-or-signup-submission/ , there is still an error saying that the record already exist

    I noticed that in process_form function, the $mask_id is used to prevent this error when using the build-in function. Maybe you could also send $mask_id as a parameter of the filter “pbd-incoming_record_match” so that it can also be used in the same way ?

    Or maybe you would have another suggestion to make it work ?

    Thank you

    natriya

    (@natriya)

    Try orderby=date,owner,code
    with lowercase and no quotes

    natriya

    (@natriya)

    Hi @master331

    Maybe this would meet your need :
    [pdb_list search_fields=time,owner,code ] (assuming time, owner and code are the name of the field in your database)

    Thread Starter natriya

    (@natriya)

    Hi @xnau

    Did you have the chance to look at this issue ?

    Thank you

Viewing 15 replies - 1 through 15 (of 50 total)