You can close the other ticket, I'll work out what the issue is here.
It's easier for me to do testing locally, so I'm going to install a copy of your site locally and debug what's happening there, and then I'll update you again here.
OK, I think I identified the problem to the slug of the second parent post selector in the $_POST object being different than I expected.
I've made what will hopefully be the final edit to the code, as follows:
<?php
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
/**
* Reset parent post ID on post edit form
*/
function ts_override_parent( $form_data ){
$form_id = '4787';
if ( $form_data['id'] == $form_id ){
// reset parent
$_POST['@buchungssystem-selbstportrat_parent'] = '4668';
$_POST['@selbstportrat-element_parent'] = '4702';
}
}
add_filter( 'cred_before_save_data', 'ts_override_parent' );
That is live on your site, if you could test one more time please.
Here, we have now the following situation: The first choice ('4703' - page) is removed. But the second choice ('4702' - page) is not connected. Right now, there is no page connected in the 'selbstportrat-element_parent'-relationship, after submitting the form.
I'm really sorry, Lara, but it's not very easy to test.
There is only one post on the site I can test with ("Night Owl"), and once I've used the edit form once, I can't use it again.
So I've edited the template for displaying the Selbstporträt posts so that it just displays the edit form directly each time (on my local copy of your site), so I've been able to submit multiple tests.
And... there is a simple error in the code I gave you.
The cred_before_save_data hook is an action, but I've added it as a filter.
I'm surprised it worked at all (it would have been easier to debug if it hadn't) rather than half-worked.
This should be the final version...
<?php
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
/**
* Reset parent post ID on post edit form
*/
function ts_override_parent( $form_data ){
$form_id = '4787';
if ( $form_data['id'] == $form_id ){
// reset parent
$_POST['@buchungssystem-selbstportrat_parent'] = '4668';
$_POST['@selbstportrat-element_parent'] = '4702';
}
}
add_action( 'cred_before_save_data', 'ts_override_parent' );
It's definitely working on my local copy of your site, if you could please check one more time.