Skip Navigation

[Resolved] Adoption & Sponsoring System for Charity Website

This support ticket is created 5 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 18 replies, has 2 voices.

Last updated by tobiasF-3 5 years, 3 months ago.

Assisted by: Nigel.

Author
Posts
#1304459

Thx a lot. I've tried the following, but the form now hangs after submission and does not proceed to the payment options?

/**
* Connect dog and contact posts to the intermediate post created by the form
*/
add_action('cred_save_data', 'ts_connect_to_intermediate', 10, 2);
function ts_connect_to_intermediate($post_id, $form_data)
{

// Edit the form ID ( 123 in the example below )
if (in_array($form_data['id'], array(210832))) {

// Edit the slug of the generic field included in the form which contains the ID of the dog
// that will be available in the $_POST object ( 'dog_id' in the example below )
$dog_id = $_POST['dog_id'];

// Retrieves contact post of current user
$contacts = get_posts( array(
'post_type' => 'contact',
'post_status' => 'publish',
'post_author' => get_current_user_id(),
'limit' => 1
) );
$contact_id = $contacts[0]->ID;

// Edit slug of relationship between dogs and contacts ( 'sponsorship' in example below )
ts_connect_existing( "doctor-sponsorship", $contact_id, $dog_id, $post_id );
}
}

#1305647

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

The code looks pretty much correct.

If the form hangs then it sounds like a fatal error. I don't see any syntax errors that would cause that, so I'm wondering if you left the code that defined the ts_connect_existing function in place (not shown above) or if you deleted it.

If you deleted it then you would get a fatal PHP error when calling a non-existent function.

You can verify that by checking your debug logs.

If you haven't already, turn on the debug log by editing your wp-config.php file and change the line with WP_DEBUG like so:

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
define('WP_DISABLE_FATAL_ERROR_HANDLER',true);

That will create a debug.log file in your /wp-content/ directory which you can examine in any text editor. Try submitting the form again and then inspect the log.

Otherwise I would double-check that "contact" is the slug of your contact post_type, and lastly, double-check that you have the contact_id and dog_id in the right order in the final line (the same order as in the relationship itself, with contact_id the left hand side of the relationship and dog_id the right hand side).

(I can't check myself because when I log in to your site I can't access the backend.)

#1305749

Thx Nigel, this was very clear and helped me solve it. I really did miss the additional code, sorry about that 🙂 and the order was different between dog_id and contact_id. It WORKS NOW! Thank you very much and for the future I have set your login to administrator so you should be able to log in the next time you help me 🙂 Thx a lot, great job!! I'll be back with more questions soon 🙂

#1305753

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Great, I'm really pleased, because it required quite a bit of thought 🙂

I think we can probably close this and you can ask any more questions in new threads (you can assign to me or ask for me to be assigned if you like).

#1305793

Absolutely, let‘s close this and see each other back with another question 🙂 thx again for your great support, I am very excited to develop the functionality of the website further now. The dogs and all of our charity are thanking you. Cheers. T