See this example on how to create and parse the shortcode in the contact form 7 to use it add [current_url]
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_current_url' );
function wpcf7_add_form_tag_current_url() {
// Add shortcode for the form [current_url]
wpcf7_add_form_tag( 'current_url',
'wpcf7_current_url_form_tag_handler',
array(
'name-attr' => true
)
);
}
// Parse the shortcode in the frontend
function wpcf7_current_url_form_tag_handler( $tag ) {
global $wp;
$url = home_url( $wp->request );
return '<input type="hidden" name="'.$tag['name'].'" value="'.$url.'" />';
}
Also if its all about to get the URL in the email you dont need all of this. there is a special tag for the email [_url]
CF7 Special mail tags
Related Posts:
- Sending form data via PHPMailer – How to action PHP script from a form
- Contact forms going into spam folder
- Add contact form
- Creating a contact form with Laravel frontend
- Can you disable the mail function in contact form 7 [closed]
- Make a form that will send email to all the authors in selected category [closed]
- Using Contact Forms to Send Private Information [closed]
- advanced custom fields and contact form 7
- form action wordpress and php
- WordPress Emails & Contact Forms [closed]
- Email from my theme’s contact form doesn’t get the reply-to address right
- Dashboard Contact Form
- How can I receive uploaded attach file as a Google drive link [closed]
- Email form getting hacked
- WordPress – Users with contact form on profile
- Why is my contact form not working?
- Contact form spam, without form?
- Custom Contact Form Not Sending (but not giving error)
- How to add contact form instead of checkout
- What is & used for
- How to define form action in JSF?
- Free or affordable OCR and ICR (handwriting recognition) SDK?
- What characters are allowed in an email address?
- Send a copy to yourself with Contact Form 7 in WordPress
- How to include landing page with form submission?
- How to edit a user profile on the front end?
- How to display user registration form on front-end of the website?
- Contact Form on WordPress Sites?
- How to handle form submission?
- What is an easy way to display a front-end user registration form?
- Add error message on password protected page
- how to set from address according to the form input email address for wp_mail()?
- Is wp_nonce_field vulnerable if you know the action name?
- How to pass on Google Adwords gclid variable to other pages
- using update_user_meta in form to set and get custom meta
- Best way to create multi-step form with data saved to user account for later updating?
- User registration problem in WordPress
- Creating a contact form without a plugin [closed]
- How to submit data from HTML form?
- Custom Registration Template/Page
- show image in mail contact form 7 [closed]
- Can I verify nonce which was generated on a different WP site?
- Submitting post to database then redirecting to paypal
- Registration form labels – add asterisk
- Autocomplete for taxonomy input boxes on a front end form
- How to create and retrieve data from a special registration form?
- Contact form 7 Dynamic text – placeholder on GET field
- Settings API erases itself?
- how to handle forms in multiple pages?
- set_query_var doesn’t seem to work on init hook
- How to send multipart form data to WordPress endpoint
- need to add attach thumbnail from my form
- Wp_mail Returning False on Server
- recommended practice for form submission
- Contact Form 7 plugin refreshing page on submit [closed]
- Placeholders in Jetpack Contact Form [closed]
- How to update selective options on plugin settings page
- Built-in data validation function for URLs
- $_POST empty on submit (same code, same form submits normally on local server)
- Gravity Forms skip form if already filled out using cookie?
- Loading scripts & styles from a meta box callback function
- Checkbox won’t check when label is clicked
- One comment per user per post
- Looking for a simple approach for handling user $_POST data without AJAX?
- Trying to save and display a wp_editor()
- How to return variables from admin-post.php
- Help with verifying google recaptcha in a custom form
- Nonce actions and names available via open source
- Setting specific image size for specific form upload file field
- Duplicating/Cloning Multiple Form Fields
- WordPress registration and contact form 7 [closed]
- Get data from dropdown and update page
- Mail Form in a modal box without plugin
- other shortcodes in Contact form 7 MAILS [closed]
- Obfuscating Email Addresses in Form Fields
- Using the WordPress selected() function
- Performing a POST action on homepage goes to posts page
- How am I able to get the value out of cookie array when I push a button?
- How do I embed a Javascript form directly into a page?
- 404 on form submit [duplicate]
- How to Process Form Request
- Form Processing
- Reset recaptcha contact form 7 [closed]
- Return to option page after running PHP script
- Saving checkbox/option list status?
- How can I add a link to a WPForms “contact us” form to the main menu?
- Customize reset password form redirect problem
- What is the valid phone number format accepted by contact-form-7 [closed]
- creating form for wp_remote_post
- How to implement post/redirect/get pattern on contact form
- How to know what submit button the user clicked?
- limit characters when posting from form
- Creating a custom multilingual form
- wordpress not displaying my form
- Creating a form contact page?
- Get Admin Email Address From External PHP page
- Adding data to an array in usermeta and displaying it in a loop
- Help with forms and nonces
- Stripe Error: must provide source or customer [closed]
- How to submit form in a PHP file in WordPress?