I have set up a Formidable Pro form which allows people to register and add a post. It works perfectly.
I have also added Formidable PayPal to require payment before the post is published. This is working too.
The post is initially created as a draft, then after payment, the post is published. The problem is when clicking the published post’s thumbnail/title to see the full post, it takes you to the home page instead of to the full post.
If the newly registered user updates their post via the same Formidable form, the post updates and the link then works fine. It’s also fine if I update that post through the WP dashboard. The link also works fine if I tell the form to automatically publish the post instead of creating it as a draft. So the problem is only occuring after a post is changed to ‘published’ by the Formidable PayPal add on.
It is as though the PayPal add on is forgetting to include the post link (post_ID ??) when changing the post from draft to published.
Am I missing something? I’m using latest version of the plugin and the add on. Also latest version of WP and theme.
In my functions.php I had initially tried the code from http://formidablepro.com/knowledgebase/formidable-paypal/
but that didn’t successfully change the post from draft to published.
So the code I’ve added is from:
http://formidablepro.com/help-desk/paypal-callback-link/
add_action('frm_payment_paypal_ipn', 'publish_paid_post');
function publish_paid_post($args){
if(!$args['pay_vars']['completed'])
return; //don't publish if the payment was not completed
if(!$args['entry']->post_id)
return; //don't publish if not linked to a post
global $wpdb;
$wpdb->update($wpdb->posts, array('post_status' => 'publish'), array('ID' => $args['entry']->post_id));
}





July 9, 2012 at 10:06 am
The problem with using the $wpdb->update line instead of wp_insert_post from the knowledge base example, is that is doesn't hit the regular WP functions. It looks like there was a missing ' mark from the knowledge base example. Please switch to that example instead.
July 9, 2012 at 5:04 pm
Ok, I've just tried the knowledge base example again now and it isn't changing the new post from draft to published. I assume the missing ' mark has been added to the example, but still didn't work for me. The new post is appearing as draft, and I can see the payment has been marked as completed in the payments table but the post hasn't been updated to 'published'.
July 10, 2012 at 2:23 pm
Okay, sorry for the bad example. I made another small change and tested to make sure it works.
(wp_update_post instead of wp_insert_post)
July 10, 2012 at 10:07 pm
Excellent, that works now.
Another item to check on; after making the payment at PayPal and clicking the link (still at PayPal) to return to our website we're seeing an alert popup.
On safari on mac, the alert is "This form will be sent in a way that is not secure. Are you sure you want to send it?" and on Firefox on Windows it is a similar alert.
Would that be resulting from use of the Formidable PayPal add-on? It would be good to know if there's a way to eliminate that alert as it would worry the customers.
July 10, 2012 at 10:19 pm
That one is all you. You should get SSL setup if you want it to pass securely.
July 11, 2012 at 7:32 pm
Got it, thanks for your help.
Topic closed.