• Resolved cinman

    (@cinman)


    Could you please add on to your example of the filter so that it shows how to create more than one additional rule? Does it require another function, or can another rule be added within the my_wpmdb_anonymization_rules function? The $config is throwing me off since it’s used so much elsewhere in the plugin and i’m novice at PHP.

    <?php
    /**
    * Anonymizes a users date of birth.
    *
    * @param array $config
    *
    * @return array
    */
    function my_wpmdb_anonymization_rules( $config ) {
    $config[‘usermeta’][‘meta_value’][] = array(
    ‘constraint’ => array( ‘meta_key’ => ‘dob’ ),
    ‘fake_data_type’ => ‘dateTimeThisCentury’,
    );

    return $config;
    }

    add_filter( ‘wpmdb_anonymization_config’, ‘my_wpmdb_anonymization_rules’ );
    ?>

Viewing 1 replies (of 1 total)
  • Thread Starter cinman

    (@cinman)

    For anyone else that may be interested, I have received a solution via email.

    Sorry for the delay, yes you were correct with just doing the same, as they get added to an array for meta_value.

    function my_wpmdb_anonymization_rules( $config ) {
    $config[‘postmeta’][‘meta_value’][] = array(
    ‘constraint’ => array( ‘meta_key’ => ‘cc_num’ ),
    ‘fake_data_type’ => ‘creditCardNumber’,
    );

    $config[‘postmeta’][‘meta_value’][] = array(
    ‘constraint’ => array( ‘meta_key’ => ‘cvv’ ),
    ‘fake_data_type’ => ‘numberBetween($min = 101, $max = 999)’,
    );

    return $config;
    }

    Cheers,
    Iain

Viewing 1 replies (of 1 total)

The topic ‘Example code for more than one extra rule’ is closed to new replies.