• Dear Support Team,

    I am reaching out to seek guidance on how to implement mandatory fields while adding products. Could you please provide me with the necessary steps or resources to achieve this?

    Thank you for your assistance.

    Best regards, Nifal

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    For a better user experience, it’d be nice to have JavaScript confirm that the mandatory fields have appropriate data right when the the user clicks the publish button. This is usually done by preventing the default action, doing the checks, then your script actually submits the data if all checks out.

    How important is it that the fields have appropriate data? Because JavaScript runs client side, it’s trivial for a user to workaround any restrictions imposed by script and make an inappropriate submission. If this needs to be prevented, the data should be checked again server side with PHP. You can use the ‘wp_insert_post_data’ filter to validate data prior to a product being inserted. To prevent insertion, you’ve little choice but to wp_die(), which isn’t very user friendly, but users would only encounter this if they had disabled or subverted your JS checks, so they kind of have it coming if they do so ??

Viewing 1 replies (of 1 total)
  • The topic ‘We need to implement a mandatory field while adding a new product.’ is closed to new replies.