Dear Sir/Madam,
I have a custom post with custom field "agreement-terms" which is WYSIWYG field type. (screenshot Screenshot 2020-11-15 at 11.20.39 AM.png)
There is content in the field (screenshot Screenshot 2020-11-15 at 11.21.11 AM.png)
I hard code the "agreement-terms" content to the production User Form (screenshot Screenshot 2020-11-15 at 11.21.38 AM.png) and [types field='agreement-terms'][/type] to UAT User Form (screenshot Screenshot 2020-11-15 at 11.22.04 AM.png)
I expected the outcome like the production site does (screenshot Screenshot 2020-11-15 at 11.22.27 AM.png) but content of the agreement-terms doesn't be showed from UAT (screenshot Screenshot 2020-11-15 at 11.22.51 AM.png).
Is there any cache from the Toolset, how can I clear it or it is not possible to show the WYSIWYG field type content to User Form? Please advise.
Best regards,
Kelvin.
I have a custom post with custom field "agreement-terms" which is WYSIWYG field type.
I hard code the "agreement-terms" content to the production User Form
Hello, it looks like you are trying to display a custom field from some post in an Edit User Form. How is the post related to the User being edited in this Form? You must have some way to access the post ID here, otherwise, the User Form does not know which post contains the WYSIWYG field information.
Is the User Form displayed on the template for the post that contains this custom field? For example, if the WYSIWYG field is on post type "A", and you place this Form in the template for post type "A", then you can use the $current_page operator to set the post ID reference for the Types field shortcode:
[types field='agreement-terms' item='$current_page'][/type]
Otherwise, you need some way to access the post ID here, and that depends on how the User is related to the post that contains the WYSIWYG field. I would need more information about this relationship to be able to give you a good recommendation.
Dear Christian Cox,
Thanks for your reply. Refer to screenshot (Screenshot 2020-11-16 at 11.16.13 AM.png), this is the part of the User Form, users must agree with the agreement terms before continuing the registration. From the User Form, I add a generic field to form and let the user apply the competition together. I customize the cred_save_date() hook to create the application record.
In the User Form, I allow the user to select the competition he/she wants to apply, see screenshot (Screenshot 2020-11-16 at 11.23.51 AM.png)
Now I want to redirect the user to the specific competition when he/she register, is it possible to allow me to make a link like /registration-application/?cp=xxx where xxx is the competition id so that I can show the corresponding agreement terms from the first screen?
Not sure whether my requirement is clear enough?
Best regards,
Kelvin.
Hi, it sounds like you would like to customize the redirect URL when this Form is submitted, using the value of a generic field in the Form. This is possible using the Forms redirection API cred_success_redirect: https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect
Here is an example of how this would work.
1. The User Form must be set to redirect to a specific page or a post after the submission. If for example, the form options are set to “Keep displaying this form” or “Display a message instead of the form” after submission, the redirection hooks will not work.
2. Customize the following custom code snippet to work for your needs:
add_filter('cred_success_redirect', 'custom_redirect_to_selected_competition',10,3);
function custom_redirect_to_selected_competition($url, $post_id, $form_data)
{
if ($form_data['id']==12345 && isset( $_POST['your-generic-field-slug'] ) )
{
return '/registration-application/?cp=' . $_POST['your-generic-field-slug'];
}else{
return $url;
}
}
You must change 12345 to match the User Form ID, and change your-generic-field-slug to match your generic field. You may need to adjust the URL as well, depending on your needs.