Skip Navigation

[Resolved] Trying to create a file system directory on save_post

This support ticket is created 5 years, 4 months 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)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 5 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#1285913

I am trying to: create a file system directory on save_post

Using php "mkdir()" function to create a directory when a CPT is saved. On regular posts, it works ok, but on CTP created via types - it doesn't.

add_action( 'save_post', 'create_manifest_on_disk' );
function create_manifest_on_disk( $post_id ) {
...
...
if (!mkdir("manifest/" . $cardSlug , 0700,true)) {
 file_put_contents ( __DIR__ . '/mylog.log', 'unabable to create directory \n', FILE_APPEND);
}
....
}

any idea why? workarounds?

Thanks

#1286227

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

The general save_post action must be used with a priority of at least 30 when used in conjunction with post types registered with Types, or inconsistencies in the updated data may be experienced.

More info:
=> https://toolset.com/documentation/customizing-sites-using-php/updating-types-fields-using-php/

#1286295

Nope, still can't create the directory. Other thoughts?

#1286401

Minesh
Supporter

Languages: English (English )

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

No - do you see any error with your site's debug log?