Skip Navigation

[Resolved] urlparam in cred form submit dont redirect to the right post

This support ticket is created 7 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 18 replies, has 2 voices.

Last updated by davidZ-4 7 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#590375

I am trying to: redirect a user to a page with a view that except urlparam after clicking cred submit button

Link to a page where the issue can be seen:
hidden link

I expected to see:
the page with the post that is called by the urlparam

Instead, I got:
the user is redirected to the page without the urlparam and get the wrong post in the view

The page hidden link use a view to display one post using url param

In genral I point to the page and spacifc post to display by using the following in my <a> tag:

href="[wpv-post-url id="1684"]/?edi=[wpv-post-id]&edp=[wpv-post-id id="$education-parent"]"

and it work great.

in the view of the single custom post i display cred edit form of the post.
i set the cred redirect to the page called above.

in the cred form i set the submit butoon including the urlparam values as followed:

[cred_field field='form_submit' value='Submit' urlparam='edi=[wpv-post-id]&edp=[wpv-post-id id="$education-parent"]' class='btn btn-primary btn-lg btn-block' output='bootstrap'

the cred submit button display:
hidden link

when clicking the submit button the user is been redirected to:
hidden link
which display the wrong post.

please advise,
thanks,

David

#590439

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

First of all - After checking debug information you shared with us, I found that you are using outdated Toolset plugins. We always recommend to run your site with latest stable release plugin version.

*** Please make a FULL BACKUP of your database and website.***
Could you please update ALL Toolset plugins to it's latest official released version. You can download latest plugin release from your accounts page:
=> https://toolset.com/account/downloads/

Now, regarding your redirection issue, CRED offers redirection hook cred_success_redirect .

For example:

add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
    if ($form_data['id']==12)
        return '<em><u>hidden link</u></em>';
    return $url;
}

Where:
- You can adjust your URL according to your need.

More info:
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

#590441

Hi Minesh,
My toolset plugins are all updated to the latest version.
I think I know what happen. I updated the plugins after submitting the ticket and the issue still stand...

I'm not looking to redirect to a permanent url using the redirect hook but rather redirect to a page on my site that get the information of what post to show based on a urlparam passed in the url.
the view on the page know how to accept these.
it the cred form that do something wired even though the urlparam are passed when the submit button is clicked.

David

#590442

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

If you updated plugins - all fine , no issue with that.

I think I know what you mean, you want to redirect to same page but with different url param with different post id - correct? If yes, you can still use the 'cred_success_redirect' hook to redirect to same page with additional param you may have.

Do I understand your issue now? if now, I need problem URL to check whats going wrong there and info what should be your expected output.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#590457

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thank you for all details but when I try to visit following link:
=> hidden link

I do not see any submit button but it shows me message "No items found" - could you please tell me is anything going wrong with the setup?

Also, with above link I need info which post it should display, could you please share clear step and expected results information.

#590461

sorry here are the steps:

got to hidden link
click submit
expecting to view hidden link
instead getting hidden link

Thanks,

David

#590479

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please check now. I've added following code to your current theme's functions.php file:

add_filter('cred_success_redirect', 'func_redirect_to_page',10,3);
function func_redirect_to_page($url, $post_id, $form_data){
    if ($form_data['id']==1719){
		return  $_SERVER['HTTP_REFERER'];
	}
        
    return $url;
}

Now, I can see the page is redirect back to same URL. Could you please confirm.

#590662

Thanks Minesh,
this is working great !

the bellow is related to a new post creation using cred form
one questions regarding the creation of a new post using a cred new post form and redirecting to the same location as above.
I would like the new education cred form hidden link to redirect in the same way to the same page.
is the following code will be correct?

add_filter('cred_success_redirect', 'func_redirect_to_page',10,3);
function func_redirect_to_page($url, $post_id, $form_data){
    if ($form_data['id']==1719 || $form_data['id']==1716){
        return  $_SERVER['HTTP_REFERER'];
    }
         
    return $url;
}

I have tried the above and added the urlparam in the new education cred post but it doesn't work on my end. but it doesn't redirect to the new post that was created.

I would expect the redirect to point to:
hidden link POST ID]&edp=[PARENT POST ID]

any thoughts?
Thanks,

David

#591146

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please tell me where you've added the CRED form "Add education analysis" to create new education?

#591423

Sure,

follow the process:
go to hidden link
click on Education need analysis button- this will create the parent post and redirect you to create new child post (education) here:
hidden link

please note that I put all my custom code in the function.php file editable here hidden link

Thanks,

David

#591427

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - you should keep all code (toolset hooks filters) whatever you have added to your current theme's functions.php file to make sure all working fine. Please do not move the code to another place as it will result in breaking something or it may have negative effect.

Please move code to your current theme's funcitons.php file and the FTP access details you shared were not working. Please share FTP access details.

#591619

Hi Minesh,
I have moved custom code to the theme function.php.
the FTP works on my end with the same credentials I provided.
please dont use a folder name in the ftp link. the folder name is a mandatory field in toolset so I wrote root folder but you dont need it so the ftp is the domain name I provided (including the subdomain name)...

Thanks,

David

#591626

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Still - FTP not working for me. Do I need to use SFTP or any port to login to FTP?

May be you can create new user for me and send me access details with Host, username, password and port if any.

#591647

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

No still FTP access is not working. I get following message:

550 SSL/TLS required on the control channel
Error:	Could not connect to server
#591654

that's strange
I'm using FileZilla with the credentials above and its working
are you omitting the folder name in the ftp link?
use hidden link
not hidden link use a folder

David