Search Results for 'fep_action_message_after_send'
-
AuthorSearch Results
-
January 3, 2018 at 10:27 pm #9579
In reply to: show and reply to specific message ID
Alex BrearleyParticipantThanks Shamin for your response. How many arguments are sent from the fep_action_message_after_send action? To use fep_get_message_with_replies function, what global do I need define or what file do I need to include?
December 6, 2017 at 10:18 pm #8361In reply to: show and reply to specific message ID
Shamim HasanKeymasterwhen message is sent
fep_action_message_after_send
is fired. first argument is message id of newly created message.If you want to show only one message then you have to custom code for that. You can use
fep_get_message_with_replies()
function to retrieve any message and show them anywhere.September 12, 2017 at 7:20 pm #6427In reply to: Disable Email for One Message
Shamim HasanKeymasterYou can add
remove_action( 'fep_action_message_after_send', array( Fep_Emails::init(), 'save_send_email'), 20, 2 );
just before usingfep_send_message()
September 6, 2017 at 11:34 am #6307In reply to: Insert Message from another application
Shamim HasanKeymasterYour attachment will not be sent with email in your approach.
From my codeadd_action ('fep_action_message_after_send', 'fep_open_emr_upload_attachments', 10, 3 );
and bellow everything move to abovefunction action_putmessage( $args ) {
. That means attachment hook have to be added first.Let me know.
September 6, 2017 at 5:41 am #6301In reply to: Insert Message from another application
Craig TuckerParticipantNo that was not it. I could not get the
fep_action_message_after_send hook
to work in this location. It would not trigger after several different approaches. My work around has been this:`
function action_putmessage( $args ) {
global $out, $admin_user_login;if( ! function_exists( ‘fep_send_message’ ) )
return false;$sender = fep_get_userdata( $admin_user_login, ‘ID’, ‘login’ );
if (!$sender) {
$out[‘errmsg’] = “No such sender ‘$admin_user_login'”;
return false;
}
$recipient = fep_get_userdata( $args[‘user’], ‘ID’, ‘login’ );
if (!$recipient) {
$out[‘errmsg’] = “No such recipient ‘{$args[‘user’]}'”;
return false;
}
$message = array(
‘message_title’ => $args[‘title’],
‘message_content’ => $args[‘message’],
‘message_to_id’ => $recipient,
);
$override = array(
‘post_author’ => $sender,
);
$message_id = fep_send_message( $message, $override );$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;
$filename = $args[‘filename’];
$newfilename = wp_unique_filename( $upload_dir, $filename );
$pathtofile = $upload_dir . $upsub . ‘/’ . $newfilename;
$content = isset( $args[‘contents’] ) ? base64_decode($args[‘contents’]) : ”;$size_limit = (int) wp_convert_hr_to_bytes(fep_get_option(‘attachment_size’,’4MB’));
$size = strlen( $content );
if( $size > $size_limit )
return false;$mime = isset( $args[‘mimetype’] ) ? $args[‘mimetype’] : ”;
if( !$mime || !in_array( $mime, get_allowed_mime_types() ) )
return false;file_put_contents($pathtofile, $content);
$attachment = array(
‘guid’ => $pathtofile,
‘post_mime_type’ => $args[‘mimetype’],
‘post_title’ => preg_replace(‘/\.[^.]+$/’, ”, basename($pathtofile)),
‘post_content’ => ”,
‘post_author’ => $sender,
‘post_status’ => ‘inherit’,);
$attach_id = wp_insert_attachment( $attachment, $pathtofile, $message_id );
}
I think it includes all the necessary checks. Can you see anything wrong with working this way? Everything works as it is. Do you have any concerns?
September 2, 2017 at 7:36 pm #6189In reply to: Insert Message from another application
Shamim HasanKeymasterPlease use following (Untested).
let me knowfunction action_putmessage( $args ) { global $out, $admin_user_login; if( ! function_exists( 'fep_send_message' ) ) return false; $sender = fep_get_userdata( $admin_user_login, 'ID', 'login' ); if (!$sender) { $out['errmsg'] = "No such sender '$admin_user_login'"; return false; } $recipient = fep_get_userdata( $args['user'], 'ID', 'login' ); if (!$recipient) { $out['errmsg'] = "No such recipient '{$args['user']}'"; return false; } $message = array( 'message_title' => $args['title'], 'message_content' => $args['message'], 'message_to_id' => $recipient, 'open_emr_args' => $args, //pass to get in attachment function ); $override = array( 'post_author' => $sender, ); $message_id = fep_send_message( $message, $override ); } add_action ('fep_action_message_after_send', 'fep_open_emr_upload_attachments', 10, 3 ); function fep_open_emr_upload_attachments( $message_id, $message, $inserted_message ){ if ( ! fep_get_option( 'allow_attachment', 1 ) || ! $message_id || empty( $message['open_emr_args']) ) return false; $args = $message['open_emr_args']; $name = isset( $args['filename'] ) ? $args['filename'] : ''; if( ! $name ) return false; $size_limit = (int) wp_convert_hr_to_bytes(fep_get_option('attachment_size','4MB')); $fields = (int) fep_get_option('attachment_no', 4); if( class_exists( 'Fep_Attachment' ) ){ add_filter('upload_dir', array(Fep_Attachment::init(), 'upload_dir')); } $mime = isset( $args['mimetype'] ) ? $args['mimetype'] : ''; $content = isset( $args['contents'] ) ? base64_decode($args['contents']) : ''; if( !$mime || !in_array( $mime, get_allowed_mime_types() ) ) return false; $size = strlen( $content ); if( $size > $size_limit ) return false; $att = wp_upload_bits( $name, null, $content ); if( ! isset( $att['file'] ) || ! isset( $att['url'] ) || ! isset( $att['type'] ) ) return false; $attachment = array( 'guid' => $att['url'], 'post_mime_type' => $att['type'], 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $att['url'] ) ), 'post_content' => '', 'post_author' => $inserted_message->post_author, 'post_status' => 'inherit' ); // Insert the attachment. wp_insert_attachment( $attachment, $att['file'], $message_id ); if( class_exists( 'Fep_Attachment' ) ){ remove_filter('upload_dir', array(Fep_Attachment::init(), 'upload_dir')); } }
September 1, 2017 at 3:30 pm #6147In reply to: Insert Message from another application
Shamim HasanKeymasterYou can see Fep_Attachment class. upload attachment is hooked to fep_action_message_after_send action. But if $_FILES[‘fep_upload’] not exists then no attachment will be uploaded. In that case you can see FEP_Email_Pipe class and see how it is done there.
December 16, 2016 at 1:49 am #1732In reply to: Sender receive a copy by mail
Shamim HasanKeymasterThis feature was there in initial versions of this plugin. But for user feedback this feature was removed many days ago. So this feature may not be included.
you can usefep_action_message_after_send
action hook to send email to sender if you need that badly. -
AuthorSearch Results