Making WordPress.org


Ignore:
Timestamp:
05/24/2018 09:33:14 PM (8 years ago)
Author:
coreymckrill
Message:

WordCamp tickets: privacy enhancements

  • Include some custom registration fields in personal data export/erasure
  • Add registration field to opt-out of the public Attendees page
  • Show data confidentiality notice on Edit Attendee screen
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/accommodations.php

    r7190 r7228  
    4949        // Metabox
    5050        add_filter( 'camptix_metabox_attendee_info_additional_rows', array( $this, 'add_metabox_row' ), 12, 2 );
     51
     52        // Privacy
     53        add_filter( 'camptix_privacy_attendee_props_to_export', array( $this, 'attendee_props_to_export' ) );
     54        add_filter( 'camptix_privacy_export_attendee_prop', array( $this, 'export_attendee_prop' ), 10, 4 );
     55        add_filter( 'camptix_privacy_attendee_props_to_erase', array( $this, 'attendee_props_to_erase' ) );
     56        add_action( 'camptix_privacy_erase_attendee_prop', array( $this, 'erase_attendee_prop' ), 10, 3 );
    5157    }
    5258
     
    335341        return 'en_US';
    336342    }
     343
     344    /**
     345     * Include the new field in the personal data exporter.
     346     *
     347     * @param array $props
     348     *
     349     * @return array
     350     */
     351    public function attendee_props_to_export( $props ) {
     352        $props[ 'tix_' . self::SLUG ] = $this->question;
     353
     354        return $props;
     355    }
     356
     357    /**
     358     * Add the new field's value and label to the aggregated personal data for export.
     359     *
     360     * @param array   $export
     361     * @param string  $key
     362     * @param string  $label
     363     * @param WP_Post $post
     364     *
     365     * @return array
     366     */
     367    public function export_attendee_prop( $export, $key, $label, $post ) {
     368        if ( 'tix_' . self::SLUG === $key ) {
     369            $value = get_post_meta( $post->ID, 'tix_' . self::SLUG, true );
     370
     371            if ( isset( $this->options[ $value ] ) ) {
     372                $value = $this->options[ $value ];
     373            }
     374
     375            if ( ! empty( $value ) ) {
     376                $export[] = array(
     377                    'name'  => $label,
     378                    'value' => $value,
     379                );
     380            }
     381        }
     382
     383        return $export;
     384    }
     385
     386    /**
     387     * Include the new field in the personal data eraser.
     388     *
     389     * @param array $props
     390     *
     391     * @return array
     392     */
     393    public function attendee_props_to_erase( $props ) {
     394        $props[ 'tix_' . self::SLUG ] = 'camptix_yesno';
     395
     396        return $props;
     397    }
     398
     399    /**
     400     * Anonymize the value of the new field during personal data erasure.
     401     *
     402     * @param string  $key
     403     * @param string  $type
     404     * @param WP_Post $post
     405     */
     406    public function erase_attendee_prop( $key, $type, $post ) {
     407        if ( 'tix_' . self::SLUG === $key ) {
     408            $anonymized_value = wp_privacy_anonymize_data( $type );
     409            update_post_meta( $post->ID, $key, $anonymized_value );
     410        }
     411    }
    337412}
    338413
Note: See TracChangeset for help on using the changeset viewer.