Extra setting send mail / sms


Home Forums Front End PM PRO Extra setting send mail / sms

This topic is: Not Resolved
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #17467
    test programmer
    Participant

    I’m trying to add two additional options to the form to send a message or an announcement. Namely the following options:

    * Send email
    * Send SMS message

    For this I have done the following:

    
    add_filter( 'fep_form_fields', function( $fields ){
      $fields['send_message_sms'] = array(
        'type'      => 'checkbox',
        'value'     => '',
        'cb_label'  => __("Send an sms", 'my_theme' ),
        'priority'  => 35,
        'where'     => array( 'newmessage', 'reply', 'shortcode-newmessage', 'new_announcement' ),
      );
    
      $fields['send_message_mail'] = array(
        'type'      => 'checkbox',
        'value'     => '',
        'cb_label'  => __("Send an email", 'my_theme' ),
        'priority'  => 35,
        'where'     => array( 'newmessage', 'reply', 'shortcode-newmessage', 'new_announcement' ),
      );
    
      return $fields;
    });
    

    In the function fep_action_message_after_send I can check if a message can be sent or not.

    But I have two problems:

    1. When sending a message, the 2 check boxes are shown. But when I create an announcement, they are not.
    2. How can I check the value of the checkboxes before the email is sent? To prevent sending if checkbox is not checked.
    #17473
    shamim
    Keymaster

    Which version of the plugin you are using? are you trying to add announcement from front-end?
    You can use fep_action_validate_form hook to check if those are checked and if not you can add an error which will prevent message/announcement sending.

    #17476
    test programmer
    Participant

    I’m using version 8.4.1. I’m trying to add an announcement in the backend. How can I make sure the checkboxes are added?

    #17478
    test programmer
    Participant

    I also don’t want to show an error, I want to prevent email sending. How can I do that?

    #17481
    shamim
    Keymaster

    It is always recommended to use latest version. If possible, update to latest version.

    In your version, you can use add_meta_box to show checkbox in announcement add page.

    to prevent email sending you can use update_post_meta( $message_id, '_fep_email_sent', time() ); in your save function.

    Again, if possible, update to latest version so that you can easily achieve this. I can provide you full code if require for latest version.

    #17499
    test programmer
    Participant

    The save function is not like this?

    add_action( 'fep_save_message', 'before_save_message', 100, 3 );
    
    function before_save_message( $message_id, $message, $update ){
    
    }
    #17502
    test programmer
    Participant

    I’ve tried to do update_post_meta( $announcement_id, '_fep_email_sent', time() ); in the action fep_save_announcement but it still got send.

    #17512
    shamim
    Keymaster

    Use like

    add_action( 'transition_post_status', function( $new_status, $old_status, $post ) {
        if ( 'fep_announcement' != $post->post_type ) {
    	return;
        }
        update_post_meta( $post->ID, '_fep_email_sent', time() );
    }, 10, 3 );
    
Viewing 8 posts - 1 through 8 (of 8 total)

You need to purchase ‘Front End PM PRO’ to create topic in this support forum.

If you already purchased ‘Front End PM PRO’ please LOGIN.