bp_admin_reinstall_emails

Delete emails and restore from defaults.

Description

(array) bp_admin_reinstall_emails(); 

Returns (array)


Usage

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

Defined (1)

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

/bp-core/admin/bp-core-admin-tools.php  
  1. function bp_admin_reinstall_emails() { 
  2. $switched = false; 
  3.  
  4. // Switch to the root blog, where the email posts live. 
  5. if ( ! bp_is_root_blog() ) { 
  6.  
  7. $switched = true; 
  8.  
  9. $emails = get_posts( array( 
  10. 'fields' => 'ids',  
  11. 'post_status' => 'publish',  
  12. 'post_type' => bp_get_email_post_type(),  
  13. 'posts_per_page' => 200,  
  14. 'suppress_filters' => false,  
  15. ) ); 
  16.  
  17. if ( $emails ) { 
  18. foreach ( $emails as $email_id ) { 
  19. wp_trash_post( $email_id ); 
  20.  
  21. // Make sure we have no orphaned email type terms. 
  22. $email_types = get_terms( bp_get_email_tax_type(), array( 
  23. 'fields' => 'ids',  
  24. 'hide_empty' => false,  
  25. 'update_term_meta_cache' => false,  
  26. ) ); 
  27.  
  28. if ( $email_types ) { 
  29. foreach ( $email_types as $term_id ) { 
  30. wp_delete_term( (int) $term_id, bp_get_email_tax_type() ); 
  31.  
  32. require_once(buddypress)->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' ); 
  33.  
  34. if ( $switched ) { 
  35.  
  36. return array( 0, __( 'Emails have been successfully reinstalled.', buddypress ) );