bp_core_install_emails

Add default emails.

Description

bp_core_install_emails(); 

Usage

  1. if ( !function_exists( 'bp_core_install_emails' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/admin/bp-core-admin-schema.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_core_install_emails(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/bp-core/admin/bp-core-admin-schema.php  
  1. function bp_core_install_emails() { 
  2. $defaults = array( 
  3. 'post_status' => 'publish',  
  4. 'post_type' => bp_get_email_post_type(),  
  5. ); 
  6.  
  7. $emails = bp_email_get_schema(); 
  8. $descriptions = bp_email_get_type_schema( 'description' ); 
  9.  
  10. // Add these emails to the database. 
  11. foreach ( $emails as $id => $email ) { 
  12. $post_id = wp_insert_post( bp_parse_args( $email, $defaults, 'install_email_' . $id ) ); 
  13. if ( ! $post_id ) { 
  14. continue; 
  15.  
  16. $tt_ids = wp_set_object_terms( $post_id, $id, bp_get_email_tax_type() ); 
  17. foreach ( $tt_ids as $tt_id ) { 
  18. $term = get_term_by( 'term_taxonomy_id', (int) $tt_id, bp_get_email_tax_type() ); 
  19. wp_update_term( (int) $term->term_id, bp_get_email_tax_type(), array( 
  20. 'description' => $descriptions[ $id ],  
  21. ) ); 
  22.  
  23. bp_update_option( 'bp-emails-unsubscribe-salt', base64_encode( wp_generate_password( 64, true, true ) ) ); 
  24.  
  25. /** 
  26. * Fires after BuddyPress adds the posts for its emails. 
  27. * @since 2.5.0 
  28. */