Thank you Minesh it looks like the snippet is saving the secret ID 2 of the old Parent and not the new Parent.
I tired following:
1- created Folder 3 and Folder 4
2- Added a File to Folder 3
3- Changed the Parent of the File to Folder 4
4- The file Disappeared from Folder 3 as well not showing in Folder 4
i Checked on the backend this is what happening:
1- when we submit the form 203, the snippet look for the custom field Secret ID 2 of current Parent and add it the custom field Secret ID 1 of child. what we need is to add the Secret ID 2 of the new Parent to the Secret ID 1.
2- Second problem is that the Secret ID 2 is a secret key that gets automatically generated with combination of small and capital letters. so when we just copy the Secret ID 2 to Secret ID 1, this copies exactly the same which is causing the files to not show up in any folder. because in the views i have conditional to show only files and folders with the secret ID 1 has the same value of the current page slug. this means when we are in Folder 2 and create Folder 3 in there the current slug of the Folder 2 get saved in the Secret ID 1 of Folder 3 as small letter because its taking the value from the slug.
I know it sounds very complicated, and even more complicated for me to explain this. but the best what we can do, is to get the slug name of the new parent to save in the child Secret ID 1.
I have uncovered the forms for creating folders and files.. you will see the secret keys there. Secret ID 1 is taking from the current page slug and the Secret ID 2 is getting by each page refresh generated.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Well - I've again adjusted the code as given under:
add_action('cred_save_data', 'parent_slug_to_custom_field', 10, 2);
function parent_slug_to_custom_field($post_id, $form_data) {
if ( ($form_data['id'] == 203) OR ($form_data['id'] == 1111) ){
// get the parent post ID
// $parent_post_id = toolset_get_related_post($post_id, 'folder-file' );
$parent_post_id = $_POST['@folder-file_parent'];
//fetch the parent post object
$parent_sec_id_2 = get_post_meta($parent_post_id,'wpcf-secret-id-2',true);
// assign the parent post slug to field wpcf-secret-id-1
update_post_meta($post_id,'wpcf-secret-id-1',$parent_sec_id_2);
}
}
If you will check database - I see that the correct field values are fetched and stored in database. Can you please confirm. Now I think the only issue you have is to display it and I do not know how and where you are displaying it.
Yes, You got it!
I think the only issue now is to make the text saved in Secret ID 1 to be small letters? once they are small letters the issue is resolved.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Great - thanks for confirmation.
Again, I chagned the following line:
// assign the parent post slug to field wpcf-secret-id-1
update_post_meta($post_id,'wpcf-secret-id-1',$parent_sec_id_2);
</cide>
To (I've applied strtolower() function)
// assign the parent post slug to field wpcf-secret-id-1
update_post_meta($post_id,'wpcf-secret-id-1',strtolower($parent_sec_id_2));
[/php]
And I can see the file in Folder 4 as well - Can you please confirm, Really glad to help you out with this really hard issue.
I am so happy with your support seriously. You did a hard job to get this issue solved, and i am glad you were so patient to understand this although its complicated Issue yes! 5 Stars for you Minesh. Thank you very much 🙂
My issue is resolved now. Thank you!