• Resolved funmusic

    (@funmusic)


    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://ww.wp.xz.cn/plugins/events-manager/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    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

    (@funmusic)

    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

    (@angelo_nwl)

    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

    (@funmusic)

    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.