shortcode into email
-
Hello,
I just testing your Hustle Plugin on my wordpress. I created a Popup, for subscribtion. And I would like insert a shortcode info the mail received.
This shortcode will be a unique link file download.
Thanks for your help;
Regards
-
Hi @narol,
Hope this message finds you well.
Currently, Hustle Pop-up Email doesn’t have such a feature, still, I notified our developers about the possibility of adding the shortcode in the Email body of the Automated Email option.
Since they work on very complex issues, getting a reply from them could take more time than usual, your patience on this is greatly appreciated.
Best regards,
LauraHi @narol,
Could you share the shortcode with us? and also which plugin is it? We have this mu-plugin but it’s from ACF shortcode, it might require a slight modification for your shortcode:
$atts, 'custom_acf_free_pdf' ); // Get the value of the ACF field named 'free_pdf' from the specified post ID $pdf_link = get_field( 'free_pdf', $atts['post_id'] ); // Check if the field has a value if( $pdf_link ) { // Return the value wrapped in an anchor tag return '<a href="' . esc_url( $pdf_link ) . '">Download PDF</a>'; } else { // If the field doesn't have a value, return nothing return ''; } } add_shortcode( 'custom_acf_free_pdf', 'custom_acf_free_pdf_shortcode' ); add_filter( 'hustle_parsed_success_message', function( $message, $module_id, $type, $data ) { // Pass the current post object to the shortcode: if ( empty( $GLOBALS['post'] ) && ! empty( $data['post_id'] ) ) { $GLOBALS['post'] = get_post( $data['post_id'] ); } // Apply the shortcodes: $message = apply_shortcodes( $message ); return $message; }, 10, 4 );
Let us know. Thanks.
Best regards,
LauraFor the moment this is just a test, an example, but I’ve tried the ‘One-Time File Download’ plugin.
https://codecanyon.net/item/wp-one-time-file-download-unique-link-generator-wordpress-plugin/21871469My need :
- My Popup asks you to leave your first name and email address in order to receive a guide (PDF file).
- The email I received contained a link to the file download.
- I don’t want people to be able to forward the email to each other to ‘share’ the file link.
- So I’m hoping that with a plugin like OTFD, I can generate a unique link for each email sent.
- The shortcode generated is: [wp_otfd id=‘1’ title=‘ebook-30-affirmations-positives’ class=‘’]
- my website address (so you can see the Popup ?? :
https://therapiebreve-bordeaux.com/
Translated with DeepL.com (free version)
Hi @narol
Thank you for response and additional explanation.
It’s clear now what you want to achieve but that’s not supported out of the box and I’m not yet sure if it would be doable.
I need to consult it with your developers so I’ve already asked them to check. They’ll look into it and if there is some workaround for this, we’ll let you know.
Note: I’d appreciate some patience. Our developers are dealing with a lot of complex tasks on daily basis so their response time may be a bit longer than ours is. We’ll update you here once we got feedback.
Best regards,
AdamHi @narol
It seems that there is a solution for this. It will require a bit of custom code to be added to the site.
Here is the code:
<?php add_filter( 'wp_mail', 'hustle_mail_shortcode_execute', 99, 1); function hustle_mail_shortcode_execute( $args ) { $subject = "YOUR_SUBJECT_HERE"; // set to be the same as your e-mail subject if ( $args['subject'] <> $subject ) { return $args; } $args['message'] = do_shortcode( $args['message'] ); return $args; }
To add it to the site:
1. create an empty file with a .php extension (e.g. “hustle-shortcode-in-mail.php”) in the “/wp-content/mu-plugins” folder of your site’s WordPress install on the server
2. copy above code and paste it into that file
3. in this line of the code
$subject = "YOUR_SUBJECT_HERE"; // set to be the same as your e-mail subject
replace YOUR_SUBJECT_HERE with an actual subject that you set for e-mail in “Automated Email” configuration of your popup; note that it must be identical (that applies even to upper/lower case) and it cannot include any “variable” parts – it must be a “fixed” subject; it’s very important.
4. save the file
5. add your shortcode to the “Email body” content of the “Automated Email” configuration.
Then it should work out of the box. I don’t have access to the same “One Time File Download” plugin but I tested it with different download plugin and it worked just fine.
Best regards,
AdamHi @narol
We haven’t heard from you in a while, I’ll go and mark this thread as resolved. If you have any additional questions or require further help, please let us know!
Kind Regards,
Kris
- The topic ‘shortcode into email’ is closed to new replies.