Created
April 19, 2019 09:37
-
-
Save RiodeJaneiroo/9350f04ba1360f3f104b7c71e8675488 to your computer and use it in GitHub Desktop.
[Wordpres Contact Form 7] Add custom tag in CF7 (Pure url) #cf7 #wordpress #contact_form_7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'wpcf7_form_elements', 'do_shortcode' ); | |
function pure_url_cf7_func() { | |
$submission = WPCF7_Submission::get_instance(); | |
$url = $submission->get_meta( 'url' ); | |
return strtok($url, '?'); | |
} | |
add_shortcode('puress_url', 'pure_url_cf7_func'); | |
wpcf7_add_form_tag('puress_url', 'pure_url_cf7_func'); | |
add_filter('wpcf7_mail_components', 'do_shortcode_mail', 10, 3); | |
function do_shortcode_mail( $components, $contactForm, $mailComponent ){ | |
if( isset($components['body']) ){ | |
$components['body'] = do_shortcode($components['body']); | |
} | |
if( isset($components['subject']) ){ | |
$components['subject'] = do_shortcode($components['subject']); | |
} | |
return $components; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment