Search Results for 'fep_action_message_after_send'

Home Forums Search Search Results for 'fep_action_message_after_send'

Viewing 15 results - 16 through 30 (of 38 total)
  • Author
    Search Results
  • #20493
    David
    Participant

    Ok, have got to this stage which has added a text box but not sure how to echo the info from the text box into the message? Is it possible to replace the word ‘hello’ below with the details entered into textbox1?

    add_filter( 'fep_form_fields', function( $fields ){
    	$fields['cus_fep_textbox1'] = [
    		'type'     => 'text',
    		'where'    => 'reply',
    		'priority' => 22,
    		'label' => 'Start Point',
    	];
    	return $fields;
    });
    
    add_action( 'fep_action_message_after_send', function( $message_id, $message, $new_message ){
    	if ( ! empty( $message['cus_fep_textbox1'] ) ) {
    		fep_add_meta( $message_id, 'cus_fep_textbox1', $message['cus_fep_textbox1'], true );
    	}
    }, 10, 3);
    
    add_action( 'fep_display_after_message', function(){
    	if ( fep_get_meta( fep_get_the_id(), 'cus_fep_textbox1', true ) ) {
    		echo hello;
    	}
    });
    
    #20489
    David
    Participant

    Hi,

    I’d like to achieve a similar thing but using 1-3 separate text boxes that would sit above the message box on the view message page. Any help with this would be much appreciated. I have tried the above but changing the ‘fep_action_message_after_send’ to ‘fep_display_before_messagebox’ but it is not working.

    #20346
    Shamim Hasan
    Keymaster

    Add following code in your theme’s (child theme’s if you are using) functions.php

    add_filter( 'fep_form_fields', function( $fields ){
    	$fields['cus_fep_checkbox'] = [
    		'type'     => 'checkbox',
    		'where'    => 'newmessage',
    		'priority' => 22,
    		'cb_label' => 'Can we use your message on the site as a story?',
    	];
    	return $fields;
    });
    
    add_action( 'fep_action_message_after_send', function( $message_id, $message, $new_message ){
    	if ( ! empty( $message['cus_fep_checkbox'] ) ) {
    		fep_add_meta( $message_id, 'cus_fep_checkbox', $message['cus_fep_checkbox'], true );
    	}
    }, 10, 3);
    
    add_action( 'fep_display_after_message', function(){
    	if ( fep_get_meta( fep_get_the_id(), 'cus_fep_checkbox', true ) ) {
    		echo 'We can use this message on the site as a story';
    	}
    });
    
    #20036
    Shamim Hasan
    Keymaster

    There is a small bug for reply message in a group. For temporary fix (upto next version release) add following code in your theme’s (child theme’s if any) functions.php

    add_action( 'fep_action_message_after_send', function( $message_id, $message, $inserted_message ){
        if( $inserted_message->mgs_parent ) {
    	$group = fep_get_meta( $inserted_message->mgs_parent, '_fep_group', true );
    	if( $group ){
    		fep_add_meta( $message_id, '_fep_group', $group, true );
    	}
        }
    }, 5, 3 );
    
    #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.
    #17461
    Craig Tucker
    Participant

    Hello Shamim,
    I updated to version 10.1.1 and all seemed to go well. However I wrote some functions to help integrate Gravity Forms and OpenEMR with messaging and now my functions do not work. Where can I get information on the database changes so I can rewrite the queries in my functions?

    My functions saved copies of completed forms to a message. And another function found new messages and sent the text to OpenEMR. We had discussed some of this in this thread:
    https://www.shamimsplugins.com/support/topic/insert-message-from-another-application/

    I do not expect you to rewrite my code but if you can look at it and if you see any obvious FEP functions I need to change or fields that no longer exist can you let me know?

    Here is an example of my functions for Gravity Forms:

    
    	add_action( 'gfpdf_post_save_pdf_5', function( $pdf_path, $filename, $settings, $entry, $form ) {
    		global $wpdb;
    		$user = wp_get_current_user();
    		$user_ID = $user->ID;	
    		$message = array(
    			'message_title' => $form['title'],
    			'message_content' => "Message Goes Here",
    			'message_to_id' => $user_ID,	
    		);
    		$override = array(
    			'post_author' => 1,
    		);
    		//Turn off email send
    		remove_action( 'fep_action_message_after_send', array( Fep_Emails::init(), 'save_send_email'), 20, 2 );
    		//Post message in Frontend PM
    		$message_id = fep_send_message( $message, $override );
    		//Prepare Attachment
    		$upload_dir = wp_upload_dir();
    		$upload_dir = $upload_dir['basedir'];	
    		$subdir = '';
    		if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
    				$time = current_time( 'mysql' );
    			$y = substr( $time, 0, 4 );
    			$m = substr( $time, 5, 2 );
    			$subdir = "/$y/$m";    
    		}
    		$upsub	= '/front-end-pm' . $subdir;
    		$copy_to_dir = $upload_dir . $upsub . '/';
    		if( ! is_dir( $copy_to_dir ) ) {
    			wp_mkdir_p( $copy_to_dir );
    		}	
    		$newfilename = wp_unique_filename( $upload_dir, $filename );
    		$pathtofile = $copy_to_dir . $newfilename;
    		copy( $pdf_path, $pathtofile );	
    		$attachment = array(
    		 'guid' => $pathtofile,
    		 'post_mime_type' => 'application/pdf',
    		 'post_title' => preg_replace('/\.[^.]+$/', '', basename($pathtofile)),
    		 'post_content' => '',
    		 'post_author' => 1,
    		 'post_status' => 'inherit',
    		);
    		//Add attachment to Frontend PM post
    		$attach_id = wp_insert_attachment( $attachment, $pathtofile, $message_id );
    		//Update user information
    		update_user_meta( $user_ID, 'payment', '' );
    		update_user_meta( $user_ID, 'renew', date("Y-m-d", time()));
    	}, 10, 5 );
    

    Documentation of what I did for OpenEMR is here:

    https://github.com/CraigT543/Sunset-Patient-Portal-with-FrontendPM/blob/master/FrontendPMmods.php

    The functions I was using are:
    fep_get_option
    fep_get_userdata
    fep_send_message

    The fields I was manipulating were:
    fep_message
    _fep_participants
    _fep_delete_by_
    _fep_participants

    Any tips you can give so my patients can be uptodate would be appreciated. Thanks.

    –Craig

    #16050
    [Resolved]

    Topic: Hook announcement send

    in forum Front End PM PRO
    test programmer
    Participant

    I’m trying to expand the functionality of sending a message and announcement. I would like to add another notification when creating a message or announcement. I’ve created another plugin to hook into the functions.

    I’ve found out how to do this with sending messages with the following:

    
    add_action( 'fep_action_message_after_send', 'send_sms_with_twilio', 100, 3 );
    
    function send_sms_with_twilio( $message_id, $message, $inserted_message ){ }
    

    This works perfectly. Then I tried this for announcements with the following:

    
    add_action( 'fep_action_announcement_after_added', 'send_something', 100, 3 );
    
    function send_something( $message_id, $message, $inserted_message ){ }
    

    The above works when sending an announcement in the frontend (url: /inbox/?fepaction=new_announcement). But the problem is this doesn’t work when sending an announcement in the backoffice (url: wp-admin/post-new.php?post_type=fep_announcement).

    How can I make it work with the backoffice?

    #15483
    Shamim Hasan
    Keymaster

    You can use fep_form_fields filter to add your field. Then fep_form_field_output_TYPE action hook to output your field. Then use fep_action_message_after_send to save that value in database. and last use fep_display_after_message to display its value in message.

    #14729
    Shamim Hasan
    Keymaster

    add following code in your theme’s (child theme’s if any) functions.php

    add_action( 'fep_action_message_after_send', function( $message_id, $message, $inserted_message ){
    	$post = array(
    		'ID'		=> $message_id,
    		'post_title'	=> $inserted_message->post_title . ' #' . $message_id,
    	);
    	wp_update_post( $post );
    }, 10, 3);
    
    Shamim Hasan
    Keymaster

    This shortcode does not support multiple recipient.
    You can use fep_action_message_after_send hook to set participants to other user but may encounter some caching issue with message count. Instead You can use fep_filter_message_before_send and pass message_to_id as array of user ids. remember it already holds current recipient (may be as string), so add only other users.

    Alex Brearley
    Participant

    If the shortcode does not support multiple users in to, would it be possible to add the users using the fep_action_message_after_send hook i.e. insert post_meta data to add that particular message ID to other users inbox?

    #9721
    Shamim Hasan
    Keymaster

    That will not be practical because every field require individual type of validation and sanitize.

    You can easily capture id from url and add that in post meta. Use code like

    
    add_action( 'fep_action_message_after_send', function( $message_id, $message, $inserted_message ){
        wp_parse_str( $_SERVER['HTTP_REFERER'], $referrer );
        $id = !empty( $referrer['id'] ) ? absint($referrer['id']) : 0; //Change id with your parameter
        //here if require check some validation
        add_post_meta( $message_id, '_your_custom_meta_key', $id );
    }, 10, 3 );
    
    #9706
    Alex Brearley
    Participant

    The ID is actually a parameter in the URL on the page that has the fep_shortcode_new_message_form shortcode on. I’m currently investigating how to provide that parameter to the fep_action_message_after_send action.

    #9680
    Shamim Hasan
    Keymaster

    When you are getting your ID (from web app)? If you can capture your ID when message sent you can add like bellow code

    
    add_action( 'fep_action_message_after_send', function( $message_id, $message, $inserted_message ){
        add_post_meta( $message_id, '_your_custom_meta_key', $id_from_web_app );
    }, 10, 3 );
    
    #9582
    Shamim Hasan
    Keymaster

    three arguments are sent from fep_action_message_after_send action.
    You can use fep_get_message_with_replies( $id ) to get message with replies of given id.
    Please see functions.php of this plugin to see code.

Viewing 15 results - 16 through 30 (of 38 total)