Do I understand correctly that what you want to happen is that someone submits the form in the New Condolence tab and that this then updates to show the new condolence post in place of the form?
I've been experimenting with the settings for Forms and it's not so straightforward.
We need to reload the same page after the form is submitted, but with URL parameters, for example, that can be used by your template to test whether the page is being loaded the first time (and the form should be added to the tab) or whether it is being reloaded after form submission and the post should be loaded in the tab instead (and the JS can set that tab to open).
You can update your Form settings so that "What to show after submitting the form:" is set to redirect back to the same page.
When the form is submitted that will reload the page with a URL parameter that specifies the form that was submitted, e.g.
site.com/page-with-form/?cred_referrer_form_id=98
So, your PHP template will know whether the page with the form is being loaded the first time, or after a form submission, because you can check the $_GET object for the cred_referrer_form_id parameter (it doesn't really matter what the value is).
So where you have a tab which shows the CRED form, you can add a conditional check for this URL parameter, and if it is present you need to display the post inside the tab instead.
But, how do you know which post?
You'll have to use the CRED API to add an additional parameter which has the post id (which you can then retrieve from the $_GET object).
See:
lien caché
https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect
Here's an example of using the API:
add_filter( 'cred_success_redirect', 'tssupp_add_id_to_redirect', 10, 3 );
function tssupp_add_id_to_redirect( $url, $post_id, $form_data ) {
if ( $form_data['id'] == 98 ){
$url .= '?pid=' . $post_id;
}
return $url;
}
There it adds the post id to a 'pid' parameter, so when the page reloads it will look something like this:
site.com/page-with-form/?pid=181&cred_referrer_form_id=98
The final part is that you will need to update your JS to test for the presence of the same cred_referrer_form_id parameter, and if it exists it should open the page on the corresponding tab.
You'll need to google what's involved in getting URL parameters with JavaScript, see this for an example:
lien caché