Skip Navigation

[Resolved] Post Forms (CRED) Redirect URL Parameter Error

This support ticket is created 6 years, 1 month 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.

Our next available supporter will start replying to tickets in about 4.05 hours from now. Thank you for your understanding.

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 4 replies, has 2 voices.

Last updated by Bobby339 6 years, 1 month ago.

Assisted by: Nigel.

Author
Posts
#1121068

Hi Nigel,

You helped me with a ticket a few hours ago: https://toolset.com/forums/topic/edit-form-redirect-with-a-url-parameter/

However, I didn't realize it (caching issue) when I tweaked the code (line 7) so it will work on more than one Post Form, it crashes my site 🙁 Can you tell me what I did wrong?

<?php
/**
 * Customise redirect URL
 */
function tssupp_custom_redirect( $url, $post_id, $form_data ){
 
    if ( $form_data['id'] == '763', '773' ) { // Edit form id
 
        $url .= '?lcp=' . $post_id;
 
    } 
 
    return $url;
}
add_filter( 'cred_success_redirect', 'tssupp_custom_redirect', 10, 3 );

Thanks!

#1121465

Nigel
Supporter

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

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

That's not valid PHP, the edit you made.

If you want to use this one more than one form, you should use in_array to check the id, like so:

<?php
/**
 * Customise redirect URL
 */
function tssupp_custom_redirect( $url, $post_id, $form_data ) {
  
    if ( in_array( $form_data['id'], array( 763, 773 ) ) ) { // Edit form id
  
        $url .= '?lcp=' . $post_id;
  
    } 
  
    return $url;
}
add_filter( 'cred_success_redirect', 'tssupp_custom_redirect', 10, 3 );
#1121651

Hi Nigel!

That fixed it! Thank you so much! One final question (I know this is beyond that Toolset support covers) but do you have a book / online course recommendation to learn PHP so I can be awesome like you?

Thank you.

#1122607

Nigel
Supporter

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

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

Sorry, not really. PHP is something I've learned over years of working with WordPress, without doing a formal course, and any books I used would be well out-of-date by now.

I'd definitely recommend taking a more formal approach than I did, though.

Googling, you'll find lots of tutorials available.

You might want to start with a course such as hidden link, and then move onto something more advanced.

#1122800

THANK YOU! I will check it out!