Version Description
Download this release
Release Info
Developer | rnevius |
Plugin | Contact Form 7 – Success Page Redirects |
Version | 1.1.0 |
Comparing to | |
See all releases |
Version 1.1.0
- cf7-success-page-redirects.php +81 -0
- readme.txt +32 -0
cf7-success-page-redirects.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Contact Form 7 - Success Page Redirects
|
4 |
+
* Description: An add-on for Contact Form 7 that provides a straightforward method to redirect visitors to success pages or thank you pages.
|
5 |
+
* Version: 1.1.0
|
6 |
+
* Author: Ryan Nevius
|
7 |
+
* Author URI: http://www.ryannevius.com
|
8 |
+
* License: GPLv3
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Verify that CF7 is active.
|
13 |
+
*/
|
14 |
+
function cf7_success_page_admin_notice() {
|
15 |
+
if ( !is_plugin_active('contact-form-7/wp-contact-form-7.php') ) {
|
16 |
+
echo '<div class="error"><p>Contact Form 7 is not activated. The Contact Form 7 Plugin must be installed and activated before you can use Success Page Redirects.</p></div>';
|
17 |
+
}
|
18 |
+
}
|
19 |
+
add_action( 'admin_notices', 'cf7_success_page_admin_notice' );
|
20 |
+
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Adds a box to the main column on the form edit page.
|
24 |
+
*/
|
25 |
+
// Register the meta boxes
|
26 |
+
function cf7_success_page_settings() {
|
27 |
+
add_meta_box( 'cf7-redirect-settings', 'Success Page Redirect', 'cf7_success_page_metaboxes', '', 'form', 'low');
|
28 |
+
}
|
29 |
+
add_action( 'wpcf7_add_meta_boxes', 'cf7_success_page_settings' );
|
30 |
+
|
31 |
+
// Create the meta boxes
|
32 |
+
function cf7_success_page_metaboxes( $post ) {
|
33 |
+
wp_nonce_field( 'cf7_success_page_metaboxes', 'cf7_success_page_metaboxes_nonce' );
|
34 |
+
$cf7_success_page = get_post_meta( $post->id(), '_cf7_success_page_key', true );
|
35 |
+
|
36 |
+
// The meta box content
|
37 |
+
echo '<label for="cf7-redirect-page-id"><strong>Redirect to: </strong></label><br> ';
|
38 |
+
$dropdown_options = array (
|
39 |
+
'name' => 'cf7-redirect-page-id',
|
40 |
+
'show_option_none' => '--',
|
41 |
+
'option_none_value' => '0',
|
42 |
+
'selected' => $cf7_success_page
|
43 |
+
);
|
44 |
+
wp_dropdown_pages( $dropdown_options );
|
45 |
+
}
|
46 |
+
|
47 |
+
// Store Success Page Info
|
48 |
+
function cf7_success_page_save_contact_form( $cf7 ) {
|
49 |
+
$cf7_id = $cf7->id;
|
50 |
+
|
51 |
+
if ( !isset( $_POST ) || empty( $_POST ) || !isset( $_POST['cf7-redirect-page-id'] ) ) {
|
52 |
+
return;
|
53 |
+
}
|
54 |
+
else {
|
55 |
+
// Verify that the nonce is valid.
|
56 |
+
if ( ! wp_verify_nonce( $_POST['cf7_success_page_metaboxes_nonce'], 'cf7_success_page_metaboxes' ) ) {
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
// Update the stored value
|
60 |
+
update_post_meta( $cf7_id, '_cf7_success_page_key', $_POST['cf7-redirect-page-id'] );
|
61 |
+
}
|
62 |
+
}
|
63 |
+
add_action( 'wpcf7_save_contact_form', 'cf7_success_page_save_contact_form' );
|
64 |
+
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Redirect the user, after a successful email is sent
|
68 |
+
*/
|
69 |
+
function cf7_success_page_form_submitted( $cf7 ) {
|
70 |
+
$cf7_id = $cf7->id;
|
71 |
+
|
72 |
+
// Send us to a success page, if there is one
|
73 |
+
$success_page = get_post_meta( $cf7_id, '_cf7_success_page_key', true );
|
74 |
+
if ( !empty($success_page) ) {
|
75 |
+
wp_redirect( get_permalink( $success_page ) );
|
76 |
+
die();
|
77 |
+
}
|
78 |
+
}
|
79 |
+
add_action( 'wpcf7_mail_sent', 'cf7_success_page_form_submitted' );
|
80 |
+
|
81 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Contact Form 7 - Success Page Redirects ===
|
2 |
+
Contributors: rnevius
|
3 |
+
Tags: contact form 7, cf7, contact form, redirect, forms, form redirect, form, success pages, thank you pages, contact form 7 add-on, cf7 redirect, cf7 success, contact form 7 redirect, contact form 7 success
|
4 |
+
Requires at least: 3.8.2
|
5 |
+
Tested up to: 4.0
|
6 |
+
Stable tag: trunk
|
7 |
+
License: GPLv3
|
8 |
+
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
+
|
10 |
+
An add-on for Contact Form 7 that provides a straightforward method to redirect visitors to success pages or thank you pages.
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
|
14 |
+
An add-on for Contact Form 7 (CF7) that provides a straightforward method to redirect visitors to success pages or thank you pages, if their messages are successfully delivered. If no message is sent, or if there is an error with the form, the user will not be redirected.
|
15 |
+
|
16 |
+
== Installation ==
|
17 |
+
|
18 |
+
1. Unzip the downloaded plugin archive.
|
19 |
+
1. Upload the inner 'contact-form-7-success-page-redirects' directory to the '/wp-content/plugins/' directory on your web server.
|
20 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
21 |
+
|
22 |
+
Please note that [Contact Form 7](https://wordpress.org/plugins/contact-form-7/) must be installed and activated in order for this plugin to be functional.
|
23 |
+
|
24 |
+
== Frequently Asked Questions ==
|
25 |
+
|
26 |
+
= Why doesn't this plugin do *insert feature here*? =
|
27 |
+
|
28 |
+
If you have a feature suggestion, I'd love to hear about it. Feel free to leave a message on the "Support" tab of the plugin page, and I'll follow up as soon as possible.
|
29 |
+
|
30 |
+
== Screenshots ==
|
31 |
+
|
32 |
+
1. The plugin will add a "Redirect to:" dropdown that contains all of your existing pages as options. This is set on each of the "Edit Contact Form" pages.
|