Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/20/2021 04:02:43 PM (5 months ago)
Author:
dcavins
Message:

Introduce BP_Optouts.

Add capability to store opt-out requests from
nonmembers who have been contacted by
communication from a BuddyPress site. These
new objects are represented by the class BP_Optout
and are stored in a new database table
wp_bp_optouts. This commit adds the following capabilities:

  • Add new class BP_Optout.
  • Add new table wp_bp_optouts.
  • Create new table on installation or upgrade.
  • Add convenience functions for adding, fetching or

deleting opt-outs.

  • Add tests for basic opt-out management.

See #8448.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/admin/bp-core-admin-schema.php

    r12886 r12898  
    4040    // Install the invitations table.
    4141    bp_core_install_invitations();
     42
     43    // Install the nonmember opt-outs table.
     44    bp_core_install_nonmember_opt_outs();
    4245
    4346    // Notifications.
     
    591594    do_action( 'bp_core_install_invitations' );
    592595}
     596
     597/**
     598 * Install database tables to store opt-out requests from nonmembers.
     599 *
     600 * @since 8.0.0
     601 *
     602 * @uses bp_core_set_charset()
     603 * @uses bp_core_get_table_prefix()
     604 * @uses dbDelta()
     605 */
     606function bp_core_install_nonmember_opt_outs() {
     607    $sql             = array();
     608    $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
     609    $bp_prefix       = bp_core_get_table_prefix();
     610    $optouts_class   = new BP_Optout();
     611    $table_name      = $optouts_class->get_table_name();
     612    $sql = "CREATE TABLE {$table_name} (
     613        id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     614        email_address_hash varchar(255) NOT NULL,
     615        user_id bigint(20) NOT NULL,
     616        email_type varchar(255) NOT NULL,
     617        date_modified datetime NOT NULL,
     618        KEY user_id (user_id),
     619        KEY email_type (email_type),
     620        KEY date_modified (date_modified)
     621        ) {$charset_collate};";
     622    dbDelta( $sql );
     623
     624    /**
     625     * Fires after BuddyPress adds the nonmember opt-outs table.
     626     *
     627     * @since 8.0.0
     628     */
     629    do_action( 'bp_core_install_nonmember_opt_outs' );
     630}
Note: See TracChangeset for help on using the changeset viewer.