Forum Replies Created

Viewing 15 posts - 16 through 30 (of 147 total)
  • Author
    Posts
  • katw
    Participant

    Hi Ally,

    Need your help urgently.

    The quform_pre_send_notification hooks are not running neither the ALL nor the element specific one _#_##.

    I am thinking it has something to do with your assumption PHPMailer $mailer ???

    I am getting emails, but the hooks are not operating so the body contents are not populated as intended.

    My email routing is going through the ZOHO MAIL plugin. https://wordpress.org/plugins/zoho-mail/

    They appear to be hooking in as wp_mail.

    The sending function is below:

    if(!function_exists('wp_mail')) {
      function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) { 
        
        $atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) );
    
        if ( isset( $atts['to'] ) ) {
            $to = $atts['to'];
        }
        if ( !is_array( $to ) ) {
            $to = explode( ',', $to );
        }
        if ( isset( $atts['subject'] ) ) {
            $subject = $atts['subject'];
        }
        if ( isset( $atts['message'] ) ) {
            $message = $atts['message'];
        }
        if ( isset( $atts['headers'] ) ) {
            $headers = $atts['headers'];
        }
        if ( isset( $atts['attachments'] ) ) {
            $attachments = $atts['attachments'];
        }
    
        if ( ! is_array( $attachments ) ) {
            $attachments = implode( "\n", str_replace( "\r\n", "\n", $attachments ) );
        }
            
    
        // Headers
        $cc = $bcc = $reply_to = array();
        if ( empty( $headers ) ) {
            $headers = array();
          } else {
             if ( !is_array( $headers ) ) {
                // Explode the headers out, so this function can take both
                // string headers and an array of headers.
                $tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) );
            } else {
                $tempheaders = $headers;
            }
            $headers = array();
    
            // If it's actually got contents
            if ( !empty( $tempheaders ) ) {
                // Iterate through the raw headers
                foreach ( (array) $tempheaders as $header ) {
                    if ( strpos($header, ':') === false ) {
                        if ( false !== stripos( $header, 'boundary=' ) ) {
                            $parts = preg_split('/boundary=/i', trim( $header ) );
                            $boundary = trim( str_replace( array( "'", '"' ), '', $parts[1] ) );
                        }
                        continue;
                    }
                    // Explode them out
                    list( $name, $content ) = explode( ':', trim( $header ), 2 );
    
                    // Cleanup crew
                    $name    = trim( $name    );
                    $content = trim( $content );
    
                    switch ( strtolower( $name ) ) {
                        case 'content-type':
                            if ( strpos( $content, ';' ) !== false ) {
                                list( $type, $charset_content ) = explode( ';', $content );
                                $content_type = trim( $type );
                                if ( false !== stripos( $charset_content, 'charset=' ) ) {
                                    $charset = trim( str_replace( array( 'charset=', '"' ), '', $charset_content ) );
                                } elseif ( false !== stripos( $charset_content, 'boundary=' ) ) {
                                    $boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset_content ) );
                                    $charset = '';
                                }
    
                            // Avoid setting an empty $content_type.
                              } elseif ( '' !== trim( $content ) ) {
                                      $content_type = trim( $content );
                                }
                               break;
                            case 'cc':
                                $cc = array_merge( (array) $cc, explode( ',', $content ) );
                                break;
                            case 'bcc':
                                $bcc = array_merge( (array) $bcc, explode( ',', $content ) );
                                break;
                            case 'reply-to':
                                $reply_to = array_merge( (array) $reply_to, explode( ',', $content ) );
                                break;
                            default:
                                $headers[trim( $name )] = trim( $content );
                                break;
                            }
                         }
                      }
                    } 
                    $data = array();
                    $fromName = get_option('zmail_integ_from_name');
                    if (!empty($fromName)) {
                         $data['fromAddress'] = get_option('zmail_integ_from_name').'<'.get_option('zmail_integ_from_email_id').'>';
                    } else {
                      $data['fromAddress'] = get_option('zmail_integ_from_email_id');
                    }
                    $data['subject'] = $subject;
                    $data['content'] = $message;
                    $toAddresses = implode(',' ,$to);
                    $data['toAddress'] = $toAddresses;
                    $urlUsingRefreshToken ='https://accounts.zoho.'.get_option('zmail_integ_domain_name').'/oauth/v2/token?refresh_token='.get_option('zmail_refresh_token').'&grant_type=refresh_token&client_id='.get_option('zmail_integ_client_id').'&client_secret='.get_option('zmail_integ_client_secret').'&redirect_uri='.admin_url().'admin.php?page=zmail-integ-settings&scope=VirtualOffice.messages.CREATE,VirtualOffice.accounts.READ';
                    $bodyAccessTok = wp_remote_retrieve_body(wp_remote_post( $urlUsingRefreshToken));
                    $respoJs = json_decode($bodyAccessTok);
                    update_option('zmail_access_token',$respoJs->access_token);
                    $urlToSend = 'https://mail.zoho.'.get_option('zmail_integ_domain_name').'/api/accounts/'.get_option('zmail_account_id').'/messages';
                    if(!empty($attachments)){
                        $data['attachments'] = $attachments;
                    }  
                    if( $content_type == 'text/html' ) {
                      $data['mailFormat'] = 'html';
                    } else {
                      $data['mailFormat'] = 'plaintext';
                    }   
                    $headers1 = array(
                             'Authorization' => 'Zoho-oauthtoken '.get_option('zmail_access_token'),
                             'Content-Type' => 'application/json'
                           );
                    
                    $data_string = json_encode($data);
                    $args = array(
                             'body' => $data_string,
                             'headers' => $headers1,
                             'method' => 'POST'
                          );
                    $responseSending = wp_remote_post( $urlToSend, $args );
                    $http_code = wp_remote_retrieve_response_code($responseSending);
                    if($http_code == '200') {
                      return true;
                    }
                    return false;
    
      }
    }

    Help please. Do we need to change the $mailer?

    in reply to: Difference between two versions … #26742
    katw
    Participant

    Hi Jeff saw your message and thought I would share a link I found to the release notes:

    https://www.quform.com/2017/09/quform-2-0-0-released

    It gives a quick update on V2 when it was launched and the changes.

    And reading the various notes for 2.0+ gives the interim changes. (see recent posts on right for the links).

    • This reply was modified 6 years, 7 months ago by katw.
    • This reply was modified 6 years, 7 months ago by katw. Reason: broken link - wouldn't be fixed
    in reply to: Word Counter #26741
    katw
    Participant

    Hi @DAsub, the methods used for determining what constitutes a ‘word’ differs between the two code modules.

    If you research a method you like and share links to the info I can have a look and see if it can be implemented consistently between Javascript and PHP.

    For example an interesting discussion about this topic read this tech note. It raises the point as to whether punctuation like ‘!’ should count, or digits etc

    The issue isn’t a Quform issue but a methodology for ‘how to count’.

    katw
    Participant

    OMG I need a drink to celebrate.

    After much detective work I found a formatDate() function that does a translation and gmt_offset correction to raw dates. This was what was missing in the code you supplied.

    After a few dismal hours of trying to replicate the steps performed by this function I was about to give up when I worked out a way to call it up instead.

    I now have a correct timestamp. Yay!

    I do however ask in a future plugin version you add a new parameter to the public function formatDate() to allow us to pass a $dateformatstring.

    And have the function return the date in the custom format specified otherwise the locale setting (as it is now).

    At the moment the date returned does not include seconds, and I need a UTC format.

    BTW

    I saw a few recent comments suggesting the WordPress date_i18n function doesn’t support all the formats Date() does.

    So anyone hooking in, using this new $customformat parameter would need to be aware of this.

    So for future release:

    1. expose date for use in hooks in all environments: ‘listview’, ‘editentry’, ‘viewentry’, ‘frontend’
    2. Add $customDateFormat parameter to formatDate() in options.php

    Many thanks, close ticket

    • This reply was modified 6 years, 7 months ago by katw. Reason: add summary
    katw
    Participant

    Hi Ally,

    I have a problem with the date returned using the code supplied.

    For example I submitted a form at 4:26PM on 18 Aug 2018. I see this timestamp in Entry View ‘additional information’ and it is correct.

    But your code Returns a date value of 2018-08-18 06:26:36.
    What happened to the ‘1’ prefix on the 24 hour clock?

    I put an echo in to shout out the value when we say var = $entry['created_at'];. It is this value I am referring to… it is showing wrong at the start.

    // Get entry or record ID (wont work for list-view)
    if (isset($_GET['page'], $_GET['sp'], $_GET['eid']) && $_GET['page'] == 'quform.entries' && $_GET['sp'] == 'view') {
    	$entryId = (int) $_GET['eid'];//Extracts from querystring
    } else {
    	$entryId = $form->getEntryId();
    }
    // Access DB and get submitted data (all)
    if ($entryId) {
    	$repository = Quform::getService('repository');//DB call
    	$entry = $repository->findEntry($entryId, $form);//Returned dataset
    	if ($entry) {
    		// $entry['created_at'] will be a datetime in the format Y-m-d H:i:s
    		$Qtime = $entry['created_at'];
    			echo '<script language="javascript">';
    			echo 'alert("Q DATE [' . $Qtime . ']");';
    			echo '</script>';
    	}
    }

    I have removed any date format settings for PHP in the QuForm Global Settings. (not that it has been working). No impact on outcome.

    Please help. I just need to get the date and be able to trust the value.

    If I do any date formatting on a compromised input value I just get a compromised output value GIGO.

    • This reply was modified 6 years, 7 months ago by katw.
    • This reply was modified 6 years, 7 months ago by katw. Reason: Fixed code indent
    katw
    Participant

    Would be great to be able to get and refer to the timestamp in ListView.

    I would like to format other fields according to the ‘age’ of the submission and can’t get the entry date value to reference.

    Use-case example:

    Field Text 1_95, with title = Urgency

    Add Hook quform_get_value_html_1_95

    If listview:

    Get entry date;
    If Entry date > 7 days then set CSS class ‘Overdue’;
    If Entry date = now then set CSS class ‘Normal’;
    If Entry date < 7 days then set CSS class ‘Action’;

    if entryview:

    If Entry date > 7 days then display icon-red;
    If Entry date < 7 days then display icon-yellow;

    if editview:

    do nothing;

    in reply to: Changing the upload file box color #26723
    katw
    Participant

    Hi, perhaps I can help?

    I had a quick look at the Global style settings and don’t see this style option listed for the filename boxes so we may need to write one of our own and insert it in the Custom CSS box.

    Do you have a link to the form? So I can take a look at the CSS style associated with the filenames.

    In admin mode the classname is called .qfb-edit-file-upload-inner

    And that is what you would target when writing a custom style to change the default color, border and text color etc

    I am guessing on the front-end the class name may omit the -edit- part of the class label. But can’t be sure until I see a form with the filename field box visible.

    What styling did you want to achieve? Drop the green background? Or change text color too?

    in reply to: File Upload element rejects .EML files #26722
    katw
    Participant

    The message text “Not a recognised format” was the text replacement for the “File not allowed” error message.

    Close ticket.

    It is working and supporting EML now. Perhaps my MIME entries hadn’t propagated. All good now.

    in reply to: File Upload Element > Array > Timestamp #26712
    katw
    Participant

    Thanks for considering the request.

    I know I could change the file name to insert a date now but not best practice. It is better to have an attribute.

    Look forward to seeing it on a future release.

    BTW I have used the hooks to build much nicer file-lists which tap into the attributes you have exposed.

    See use case attached. Image it with a timestamp 😉

    Attachments:
    You must be logged in to view attached files.
    in reply to: File Upload element rejects .EML files #26710
    katw
    Participant

    Could it be coming from the ADVANCED UPLOAD component as this is enabled for this field.

    The error is front-end generated (before submit).

    Hence the advanced upload item I have pointed out.

    I will poke around.

    You can test it at: contact form

    katw
    Participant

    Yes I tried to use getEntryID() and fell on my face 😉 Same with {date} token.

    Can your function be used for edit-entry too? You didn’t specifically mention that.

    My use-case: I want to extract date parts and generate a job-id. So need it in all admin modes.

    Many thanks

    in reply to: Word Counter #26708
    katw
    Participant

    Hi Ally,

    Use the solution as you wish to write up a V2 Document.

    P.S interested in feedback. Did I interpret the validation actions correctly?

    in reply to: How to display HTML fields in Edit Entry mode #26707
    katw
    Participant

    Yes I can see a use case for HTML and without HTML fields.

    In my case I was using the HTML fields for delimiters/dividers between form sections therefore it made sense to have them in admin mode.

    I suppose it would be hard to write a hook to allow you to insert html between field elements in admin view/edit mode?

    With say a after element_ID parameter. Much like CSS :Before and :After.

    in reply to: Tool tip background colour #26689
    katw
    Participant

    Hi Nathan,

    It is IMO a style error in the release package.

    It is fairly normal during development to tinker with background-colours (helps you see the changes you make). I think they forgot to reset it back to normal. It happens to the best of us.

    I’m sure (after they read through our conversation) they will add it to bug fixes for next update.

    All the best

    in reply to: Tool tip background colour #26685
    katw
    Participant

    Found the culprit, a rogue style and unintentional I’m sure.

    .quform-theme-minimal .quform-tooltip-icon {
        background: red;
    }

    Have a look in QuForm > FORM > Settings > Style > Global > Theme

    You are using ‘Minimal’ Theme and it has a CSS styling oops…

    To fix this, goto QUFORM > Settings > Custom CSS

    add:

    .quform-theme-minimal .quform-tooltip-icon {
        background: none;
    }

    And clear quform cache if it doesn’t take and if it is still being a pest add !important before the semi-colon.

    BTW you should change password now 😉

    • This reply was modified 6 years, 8 months ago by katw. Reason: BTW
Viewing 15 posts - 16 through 30 (of 147 total)
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy