Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('.wpcf7-form').on('submit', function (e) {
- $.ajax({
- type: "post",
- dataType: "json",
- url: js_object.ajax_url,
- data: {
- action: "custom_reg_code",
- },
- success: function (response) {
- if (response.success) {
- $('#reg_code').val(response.data)
- }
- else {
- console.log('Something wrong')
- }
- },
- error: function (jqXHR, textStatus, errorThrown) {
- console.log('fail: ' + textStatus, errorThrown);
- },
- complete: function() {
- }
- })
- })
- [dynamichidden custom_reg_code “CF7_custom_reg_code”]
- function generateRandomString($length = 10) {
- return substr(str_shuffle(str_repeat($x='0123456789', ceil($length/strlen($x)) )),1,$length);
- }
- function wpse306816_CF7_custom_reg_code() {
- return date("Ymd") . generateRandomString();
- }
- add_shortcode('CF7_custom_reg_code', 'wpse306816_CF7_custom_reg_code');
Add Comment
Please, Sign In to add comment