Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 168 characters in body
Source Link

I have in my theme custom post types (products) with some meta-boxes. My client asked me, to automaticly give a unique SKU (meta-box) while saving that product.

My thought:

Give a random ID => have to check if that ID somewhere else exists OR

Give the Post-ID => that is just possible after saving once, cuz WP assign that ID while saving.

@Milo Give"additionally, a random ID => have to check if thatnew post already has an ID somewhere else existsbefore the user saves the post" GiveHow can I get the Post-ID => that is just possible after saving once, cuz WP assign that ID while saving.

Anyone got an idea to resolvebefore I save the post and put it into that elegantmeta box and save it with a new post at once?

Thanks

I have in my theme custom post types (products) with some meta-boxes. My client asked me, to automaticly give a unique SKU (meta-box) while saving that product.

My thought: Give a random ID => have to check if that ID somewhere else exists Give the Post-ID => that is just possible after saving once, cuz WP assign that ID while saving.

Anyone got an idea to resolve that elegant?

Thanks

I have in my theme custom post types (products) with some meta-boxes. My client asked me, to automaticly give a unique SKU (meta-box) while saving that product.

My thought:

Give a random ID => have to check if that ID somewhere else exists OR

Give the Post-ID => that is just possible after saving once, cuz WP assign that ID while saving.

@Milo "additionally, a new post already has an ID before the user saves the post" How can I get the ID before I save the post and put it into that meta box and save it with a new post at once?

Thanks

Source Link

Give a unique ID while saving

I have in my theme custom post types (products) with some meta-boxes. My client asked me, to automaticly give a unique SKU (meta-box) while saving that product.

My thought: Give a random ID => have to check if that ID somewhere else exists Give the Post-ID => that is just possible after saving once, cuz WP assign that ID while saving.

Anyone got an idea to resolve that elegant?

Thanks