Home › Forums › Front End PM PRO › Help with Version 10.1.1 Database Changes
Tagged: GravityForms, OpenEMR
- This topic has 4 replies, 2 voices, and was last updated 6 years, 3 months ago by Craig Tucker.
-
AuthorPosts
-
September 16, 2018 at 8:13 pm #17461Craig TuckerParticipant
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_messageThe fields I was manipulating were:
fep_message
_fep_participants
_fep_delete_by_
_fep_participantsAny tips you can give so my patients can be uptodate would be appreciated. Thanks.
–Craig
September 16, 2018 at 8:29 pm #17464Craig TuckerParticipantAnd to clarify, the problem I am having with GravityForms is inserting the PDF of the form with the message. The Message is posting fine. But my pdf file of the form is not inserted anymore. So I am supposing that the field that held the attachment data has changed in some way?
And the problem with the OpenEMR is that I am not able to grab new messages and pull them into OpenEMR anymore. So I imagine the problem is that one of these fields or functions has changed or no longer exists or there is a new dependency that I need to include in my query:
fep_get_option
fep_get_userdata
fep_send_messagefep_message
_fep_participants
_fep_delete_by_
_fep_participantsSeptember 16, 2018 at 9:26 pm #17470Craig TuckerParticipantWhat I see is that you have moved all messages to their own table: wp_fep_messages
That changes a lot. So for Gravity Forms what I need to understand is how attachments are assigned to messages now.
For OpenEMR since all messages are in their own table now I will need to completely re write the query for that table obviously. I am wondering about your use of the wp_postmeta table. In the old system it was being used to track participants, deletions of messages with pm_delete and _fep_delete_by_; then clearing of messages with pm_clear.
Since we are no longer using the post table, p.post_type = ‘fep_message’ is not necessary. That should simplify the query.
Am I on the right track?
September 16, 2018 at 9:56 pm #17472Shamim HasanKeymasterI am really sorry for issue arise. In this major version plugin performance is highly improved. So some of the function could not be backward compatible.
To see full changes of this plugin please see https://github.com/shamim2883/front-end-pm
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_status_to_publish', array( Fep_Emails::init(), 'send_email'), 99, 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( 'att_file' => $pathtofile, 'att_mime' => 'application/pdf', ); //Add attachment to Frontend PM post FEP_Attachments::init()->insert( $message_id, $attachment ); //Update user information update_user_meta( $user_ID, 'payment', '' ); update_user_meta( $user_ID, 'renew', date("Y-m-d", time())); }, 10, 5 );
I have corrected above code (untested), Please check.
For query messages new class
FEP_Message_Query
added. Please use this class. You can go to class-fep-messages.php and see user_messages method to see how it is used. You can also see FEP_Message_Query class __construct to see what args you can pass.Let me know if any more assistance needed.
September 16, 2018 at 10:43 pm #17474Craig TuckerParticipantThanks, your edit is perfect:
$attachment[] = array( 'att_file' => $pathtofile, 'att_mime' => 'application/pdf', ); //Add attachment to Frontend PM post FEP_Attachments::init()->insert( $message_id, $attachment );
I can clearly see that your modification the the database is much better. Now on to OpenEMR. I will look at
FEP_Message_Query
. Thanks again,
Craig -
AuthorPosts
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.