Title: problems changing options from code
Last modified: August 21, 2016

---

# problems changing options from code

 *  Resolved [funmusic](https://wordpress.org/support/users/funmusic/)
 * (@funmusic)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/problems-changing-options-from-code/)
 * Hi,
 * I want to change the options (specifically mails sent) and I saw a way to do 
   it through code. We do it already directly on the options, but we want a more
   automatic way to do it. I am following the instuctions at templates/format/readme.
   txt but it doesn’t work, so I may have made some mistake.
 * I put a file bookings_contact_email_body.php inside the directory my-theme\plugins\
   events-manager\formats with a very simple content (hello), and also tried `<?
   php echo "hello";?>`
 * then on my functions.php I put this:
 *     ```
       function my_em_custom_formats($array)
       {
       	$my_formats = array('dbem_bookings_contact_email_body');
       	return $array + $my_formats;
       }
       ```
   
 * add_filter(’em_formats_filter’, ‘my_em_custom_formats’, 1, 1);
 * Is there anything else I have to do? Did I do anything wrong.
 * Thanks.
 * [http://wordpress.org/plugins/events-manager/](http://wordpress.org/plugins/events-manager/)

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

 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/problems-changing-options-from-code/#post-4007915)
 * you can try something like this
 *     ```
       function my_free_event_message( $msg, $EM_Booking ){
   
       if ($EM_Booking->get_price() == 0 && $EM_Booking->get_status() == 0 ) {
       //only if event is free and pending, make it == 1 for confirmed bookings
       $msg['user']['subject'] = 'New Subject';
       $msg['user']['body'] = 'New email body';
   
       }
       return $msg;
       }
   
       add_filter('em_booking_email_messages','my_free_event_message',10,2);
       ```
   
 *  Thread Starter [funmusic](https://wordpress.org/support/users/funmusic/)
 * (@funmusic)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/problems-changing-options-from-code/#post-4007978)
 * Thanks. I guess that doesn’t modify the wp_options content. It is a possibility
   but there are other options I want to modify (like the format of the header of
   the events), that can’t be achieved that way.
 * Maybe it is an option to do directly sql queries on activation of our custom 
   plugin. I just wanted to do it the way it is supposed to be done.
 * By the way, if the code I posted is correct (even if it doesn’t work for unknown
   reasons) I’ll mark the question as resolved.
 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/problems-changing-options-from-code/#post-4008104)
 * did you paste your code above in your theme functions.php ? also, maybe you can
   try to add filter on dbem_bookings_contact_email_body
 * e.g.
 *     ```
       function my_dbem_bookings_contact_email_body(){
         return "test";
       }
       add_filter('get_option_dbem_bookings_contact_email_body','my_dbem_bookings_contact_email_body');
       ```
   
 *  Thread Starter [funmusic](https://wordpress.org/support/users/funmusic/)
 * (@funmusic)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/problems-changing-options-from-code/#post-4008108)
 * Yes, this code was on functions.php. Thanks, the filters are a possibility if
   there is one for each events manager option. I also discover the functions add_option
   and update_option from the wordpress api that can are a bit better than doing
   the query myself.

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

The topic ‘problems changing options from code’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

## Tags

 * [format](https://wordpress.org/support/topic-tag/format/)
 * [mail](https://wordpress.org/support/topic-tag/mail/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * 4 replies
 * 2 participants
 * Last reply from: [funmusic](https://wordpress.org/support/users/funmusic/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/problems-changing-options-from-code/#post-4008108)
 * Status: resolved