I'm trying to integrate PayPal Payment with Contact Form 7 in WordPress, and my Redirect isn't working - wordpress

I'm working on a Charity site where we want to accept membership payments and donations via paypal.
I am having a problem with Contact Form 7 and redirection to PayPal with a variable payment amount. I'm really hoping that someone can assist or shed some insight on this problem for me.
I read This Post, which made it sound quite easy but, while my email is being sent, the form isn't redirecting to PayPal, in fact it's not doing anything at all, not even giving me the "thank you your form has been submitted" notice.
my form has this line: £[text* AmountPaying 6/ id:PayingThis]
And under "Additional Settings" I have inserted this:
<script>
function my_redirect() {
var price = document.getElementById("PayingThis").value;
var url = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=#####&currency_code=GBP&amount="+price+"&return=http://www.example.org/join-or-renew-your-membership-online/";
window.location = url;
}
</script>
on_sent_ok: "my_redirect();"
does anybody have any experience with this ?

Thanks for the comments !
With some help troubleshooting from a friend I have figured out how to make this happen with contactForm7 - in fact, I believe you could extend this solution, and submit a lot of dynamic information directly to PayPalmy problem.
This is what I did - and it's essentially the same as this guy does here
BUT, instead of putting that code in the "ADDITIONAL SETTINGS" Area of the CF7 Form page - I added this:
<script>
function my_redirect() {
var price = document.getElementById("PayingThis").value;
var url = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=#######&currency_code=GBP&amount="+price+"&return=http://www.example.org/join-or-renew-your-membership-online/";
window.location = url;
}
</script>
up at the top, with the rest of the Form building html and tags, just before the code for the form itself:
Your Name (required): [text* your-name]
etc.
and then in the Additional settings box.. I only called the function
on_sent_ok: "my_redirect();"
and it worked! it takes the value the user enters in the "How much do you want to give us" box, and submits it to paypal
I hope others can benefit from this
thanks again for taking the time to view and help
-5tratus

Contact Form 7 is a great plugin but creating a form for PayPal gets a little tricky. Gravity Forms would be a great options but you would need the developers license that cost $200.
My recommendation is to look up the PayPal form API and create the form yourself, from scratch and integrate it OR you should have a look at the Advanced Custom Fields plugin, and the PayPal Field Add-on for Advanced Custom Fields! It's all free.
It enables you to set a form on any post/page/etc with a paypal button. All you have to do is add the <?php the_field('NAME_OF_YOUR_FIELD'); ?> to your template, wherever you want to display it.
http://wordpress.org/plugins/advanced-custom-fields/
http://wordpress.org/plugins/advanced-custom-fields-paypal-field/

Thanks 5tratus. Works.
An old support thread (https://wordpress.org/support/topic/contact-form-7-paypal-integration-1) was getting as far as redirecting to PayPal, but then PayPal was giving an "Page Not Found" "You have requested an outdated version of PayPal" message.
I didn't need price or any extra variables, so I cleaned it up to just redirect to the product page. Here's what I used and it works:
<script>
function my_redirect() {
var url = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=[PUT YOUR BUTTON ID HERE]";
window.location = url;
}</script>
As 5tratus says, put the above code in at the bottom of the form code itself, then put
on_sent_ok: "my_redirect();"
in the "additional settings" part.
Refer this useful plugin - https://wordpress.org/plugins/contact-form-7-paypal-extension/

Related

Redirect "dumb" URL to Author's custom post

I have created a website whereby users register and create their own templated profile pages. The profile pages are automatically created as Custom Posts upon registration, with the user being set as the Author of their specific post (profile).
(Users can only ever have one Custom Post)
I want to redirect a "dumb" URL like www.website.com/my-profile to a user's custom post when they are logged in.
For example, when John Smith visits www.website.com/my-profile he is directed to his profile page: www.website.com/users/john.smith
I have found many PHP solutions going the other way, but I can't seem to find a solution that does what I need. Any help would be greatly appreciated. Thanks!
This may not be the correct answer to the original query, but proved to be a solid workaround:
Instead of redirecting www.website.com/my-profile to www.website.com/users/john.smith every time it is entered in the URL bar, I created a shortcode that could be used when needed throughout the site.
add_shortcode('bt_redirect_user_link', 'bt_redirect_user_link');
function bt_redirect_user_link ($atts) {
// check if user is logged in
if (is_user_logged_in()) {
// get current user object
$current_user = wp_get_current_user();
// get user nickname
$user_nickname = $current_user->data->user_nicename;
// set the link href
$link_href = '/users/' . $user_nickname;
// output the link html
return $link_href;
}
}
Fortunately for me, the www.website.com/my-profile link (which needs to be redirected) is only available on buttons/icons visible to logged in users. This may not be a fully workable solution for websites that need to display the link to logged out users, and I assume IF/ELSE statements would needed to be added in those cases.

WordPress contact form 7 redirection

I want redirect contact us form 7 , for different pages,
I have multiple custom posts, and I want that when the user wants to read this, then first fill a form, and then redirect to full page. I want this process for every single post.
My test case can be seen here.
I am doing this:
on_sent_ok: "location.replace('http://polestarllp.com/casestudy/benefits-of-sql-on-hadoop/');"
But this is for only one page.
If it doesn’t work, check if Ajax is correctly working on your site.
follow this link
http://contactform7.com/redirecting-to-another-url-after-submissions/
For redirecting your contact form after submission . This is perfect method ,
on_sent_ok: "location.replace('http://polestarllp.com/casestudy/benefits-of-sql-on-hadoop/');"
But if you getting any issue then you can use redirection addon for contact us plugin .may be these link help you.
1:https://wordpress.org/plugins/tags/redirect-cf7/
2:https://github.com/anup04sust/Contact-Form-7-Redirect/blob/master/contact-form-7-redirect.php
3:https://github.com/kasparsd/contact-form-7-extras/blob/master/plugin.php
you need to call post id instead of this link ('http://polestarllp.com/casestudy/benefits-of-sql-on-hadoop/')
on_sent_ok: "location.replace('<a href="'. get_permalink($post->ID) . '"');"
hope it will work for you

How to submit a Contact Form without sending email?

I have Contact Form 7 and Contact Form DB installed on my WordPress site, but don't and don't want to have a mail server. At this moment, I can collect form information from Contact Form DB, so is there any ways to disable the mailing function of a submit button?
Adding this into the Additional Settings section makes it stop mailing.
demo_mode: on
Add this code to your plugin or functions.php
add_filter('wpcf7_skip_mail', 'yourname_wpcf7_skip_mail');
function yourname_wpcf7_skip_mail()
{
return true;
}
It works for me.
There may have been some changes. For example, on current version setting demo_mode: on will result in database not being filled with forms.
Use skip_mail: on instead.
From the official website:
The skip_mail setting works in the almost same
manner as the demo_mode, but the skip_mail skips the mail sending
only. Unlike demo_mode, skip_mail doesn’t affect other activities like
storing messages with Flamingo.
Source:
https://contactform7.com/additional-settings/

Wordpress - Adding javascript to head on successful submission of contact form 7

I am trying to write a plugin that allows me to output HTML or Javascript to the head section of my page when a user successfully submits a Contact Form 7.
I have tried using wpcf7_before_send_mail, but am having no success.
Thanks in advance for any help
You can add to Additional Settings field of Contact Form (official doc shows redirect http://contactform7.com/redirecting-to-another-url-after-submissions/)
on_sent_ok: "customFunction();"
and then do whatever you want in that function
<script>
function customFunction() {
}
</script>

Wordpress Form Submit button GETS (or POSTS) form data to external page

We have a wordpress website that does marketing display, but now we want to allow a customer to submit an email and selection to a separate website with a landing page that will handle the backend DB work and finish them in the other website.
Something like,
www.ourmarket.com/getdata (on Submit button click GETS to...)
www.ouradminsite/landingpage.aspx (which processes the data that the use will not see then...)
www.ouradminsite/login.aspx (where the user can now login)
I am not familiar with WP at all, but I was able to create a page with a form that has the textbox/combobox I need.
I thought it would be something simple, but somehow it seems not. I read about AJAX and doing something in functions.php and creating a custom .js file, but when working on the marketing site I find no way to add this type of function in.
My fall back is to have the WP page just have a link to a generic landing page where they enter data, but it would be visually jarring to the customer unless I duplicate the WP site for one page.
Is there an easy way to just tell WP to redirect to an external page with a GET?
UPDATE--------------
I like to think I'm making progress. I found a link that may have given me a good start. I added a function to the functions.php file located in my WP theme. It starts like this:
add_action("gform_post_submission_4", "set_post_content", 10, 2);
function set_post_content($entry, $form){
//Gravity Forms has validated the data
//Our Custom Form Submitted via PHP will go here
// Lets get the IDs of the relevant fields and prepare an email message
$message = print_r($entry, true);
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);
// Send
mail('myuser#mycompany.com', 'Getting the Gravity Form Field IDs', $message);
**wp_redirect("http://my.hearbuilder.com/hellomoto.aspx",301);**
}
From there I tried to edit the function to do that wp_redirect, just a simple one to start. This is added under the mail statement:
wp_redirect("http://my.hearbuilder.com/hellomoto.aspx",301);
From this link, when I fill out the form I can get the email, but the new page did not display. I added the exit; line and still got the same result, the page seems like it hangs.
The end result is that I need to have the new website landing page display (after it processes the data from the Wordpress form.
What am I still missing?
yes use wp_redirect()
if($_POST):
$textbox=$_POST['textboxname'];
$url= 'url'.'?custom=hello&textbox='.$textbox.'&anothervalue='.$anothervalue;
wp_redirect($url);
exit;
endif;
you can easily add the variables to the string as needed. The easiest way to control the url properly is to post the information to the same page , catch the post and redirect (place before get_header call or any output has started)
The other way is php Curl which is more difficult esp when dealing with .asp pages, but if you have access to the other server it makes figuring it out easier!

Resources