Title: override function
Last modified: August 30, 2016

---

# override function

 *  Resolved [draco_ghost](https://wordpress.org/support/users/draco_ghost/)
 * (@draco_ghost)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/override-function-2/)
 * I need to add a functionality to the plugin, for that i need to override the 
   original function named “my_calendar_send_email” in my-calendar-core.php archive,
   is there a way to achieve this ?
 * [https://wordpress.org/plugins/my-calendar/](https://wordpress.org/plugins/my-calendar/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Joe Dolson](https://wordpress.org/support/users/joedolson/)
 * (@joedolson)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/override-function-2/#post-6281138)
 * Well, it depends on what you need to do. I’d recommend just leaving the default
   email function disabled in settings, then attach your own custom function to 
   the ‘mc_save_event’ action.
 *  Thread Starter [draco_ghost](https://wordpress.org/support/users/draco_ghost/)
 * (@draco_ghost)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/override-function-2/#post-6281142)
 * I just need to add some emails dynamically to BCC, depending of the category 
   of the event and the role of the users, without typing in the area text of the
   settings of the plugin, is just this
 *  $bcc .= $mail_users; // new line, string of mails
 *  if ( $bcc ) {
    $bcc = explode( PHP_EOL, $bcc ); foreach ( $bcc as $b ) { $b 
   = trim( $b ); if ( is_email( $b ) ) { $headers[] = “Bcc: $b”; } }
 *  Plugin Author [Joe Dolson](https://wordpress.org/support/users/joedolson/)
 * (@joedolson)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/override-function-2/#post-6281170)
 * Here’s what I’d suggest, then. Change the line where $bcc is assigned from
 * `$bcc = get_option( 'mc_event_mail_bcc' );`
 * to
 * `$bcc = apply_filters( 'mc_event_mail_bcc', get_option( 'mc_event_mail_bcc' ),
   $details );`
 * I’ll add this change into my next release; the other email fields are filterable,
   it just makes sense that the BCC field should be filterable the same way the 
   others are.
 *  Thread Starter [draco_ghost](https://wordpress.org/support/users/draco_ghost/)
 * (@draco_ghost)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/override-function-2/#post-6281337)
 * \`can you add an extra argument $event ?
    Because in my case, i need to know 
   the category of the event.
 * apply_filters( ‘mc_event_mail_bcc’, get_option( ‘mc_event_mail_bcc’ ), $details,
   $event);
 * I do this way
    in my functions.php
 *     ```
       function custom_mc_event_mail_bcc($details,$event){
   
           $category_name = (string)$event['category'];
           $category_name = strtolower($category_name);
   
           if($category_name == "intermedio / avanzado"){
             $category_name = "int_ava";
           }
   
           $args = array(
             'blog_id'      => $GLOBALS['blog_id'],
             'role'         => $category_name,
            ); 
   
           if(isset($args)){
             $blogusers = get_users( $args) ;
             $mail_users = "";
             foreach ( $blogusers as $user ) {
               $mail_users .= "\r\n".esc_html( $user->user_email )."\r\n";
             }
           }
           return $details." ".$mail_users;
       }
   
       add_filter('mc_event_mail_bcc', 'custom_mc_event_mail_bcc',10,3);
       ```
   
 *  Plugin Author [Joe Dolson](https://wordpress.org/support/users/joedolson/)
 * (@joedolson)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/override-function-2/#post-6281351)
 * The $details array includes that information; $details is an expanded architecture
   of the $event object.
 * You’ll find it by name under `$details['category']` and by ID under `$details['
   cat_id']`.
 *  Thread Starter [draco_ghost](https://wordpress.org/support/users/draco_ghost/)
 * (@draco_ghost)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/override-function-2/#post-6281352)
 * yes thats right,i dont need $event, thanks for your time and help.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘override function’ is closed to new replies.

 * ![](https://ps.w.org/my-calendar/assets/icon-256x256.png?rev=1097576)
 * [My Calendar - Accessible Event Manager](https://wordpress.org/plugins/my-calendar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/my-calendar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/my-calendar/)
 * [Active Topics](https://wordpress.org/support/plugin/my-calendar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/my-calendar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/my-calendar/reviews/)

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)

 * 6 replies
 * 2 participants
 * Last reply from: [draco_ghost](https://wordpress.org/support/users/draco_ghost/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/override-function-2/#post-6281352)
 * Status: resolved