Hi, thank you very much first of all, I can not send a variable name to a php script per post to insert it in the database, but the other variable of the form if it propagates, I do not see where I can anymore be doing things wrong.
Achievement to spread the id and email but the name nothing.
The form is this.
<div class="text-center" v-show="email_locker">
<p class="text-center"><?php _e('Enter your email to download this file!', 'onyxfiles'); ?></p>
<div v-show="show_alert" class="alert {{ alert_class }}">{{ alert_message }}</div>
<form id="jkof_emailDLForm" novalidate v-on:submit.prevent="submit_email">
<div class="form-group">
<label><?php _e('Enter E-mail', 'onyxfiles'); ?></label>
<input type="email" id="jkof_inputEmail" class="form-control" name="jkof_email" style="width:100%;">
<label>Nombre</label>
<input type="text" id="jkof_inputName" class="form-control" name="jkof_name" style="width:100%;">
</div>
<div class="form-group">
<button type="submit" class="rcw-purple rcw-medium rcw-button-7 btn-block">
<span class="icon-bg"></span><span class="button-icon fa fa-envelope"></span> <?php _e('Submit & Download File', 'onyxfiles'); ?>
</button>
</div>
</form>
<button type="button" class="rcw-silver rcw-small rcw-button-7 btn-block" v-on:click="go_back('email_locker')">
<span class="icon-bg"></span><span class="button-icon fa fa-arrow-left"></span> <?php _e('Go Back', 'onyxfiles'); ?>
</button>
</div>
json's function is this
submit_email: function(){
this.show_alert = true;
this.alert_class = 'alert-info';
this.alert_message = jkof_dl_i18n.wait + ' ' + jkof_dl_i18n.adding_email;
var formObj = {
action: 'jkof_check_email',
fid: this.file_id,
jkof_email: $("#jkof_inputEmail").val(),
jkof_name: $("#jkof_inputName").val()
};
$.post( jkof_ajax_url, formObj, function(data){
if(data.status == 2){ // Instant
app.alert_class = 'alert-success';
app.alert_message = jkof_dl_i18n.success + ' ' + jkof_dl_i18n.getting_download;
app.check_download(app.file_id);
}else if(data.status == 3){
app.alert_class = 'alert-success';
app.alert_message = jkof_dl_i18n.success + ' ' + jkof_dl_i18n.emailing_download;
}else{
app.alert_class = 'alert-danger';
app.alert_message = jkof_dl_i18n.denied;
}
});
}
And finally the script that manages it and that does not collect the name is this
function jkof_check_email(){
global $wpdb;
$output = array('status' => 1);
$email = secure($_POST['jkof_email']);
$nomb = $_POST['jkof_name'];
$fid = intval($_POST['fid']);
$file_settings = get_post_meta( $fid, 'jkof_dl_settings', true );
$jkof_settings = get_option( 'jkof_settings' );
$fields = array();
if(empty($file_settings) || !filter_var($email, FILTER_VALIDATE_EMAIL)){
$output['swag']=$email;
wp_send_json($output);
}
/*if(empty($nomb)) {
wp_send_json($output);
}*/
$domain_email = array_pop(explode('@', $email));
if(in_array($domain_email, $jkof_settings['blocked']['domains']) || in_array($email, $jkof_settings['blocked']['emails'])){
wp_send_json($output);
}
foreach( $_POST as $fk => $fv ){
if($fk == 'jkof_email'){
array_push($fields, array(
'email' => $email,
'name' => $nomb
));
continue;
}
}
$wpdb->insert(
$wpdb->prefix . 'of_emails',
array(
'form_fields' => json_encode($fields),
'fid' => $fid,
"time_sent" => time()
),
array( '%s', '%d', '%d' )
);
I do not know what it can be, because the problem is between the json and the php that collects the data by post, it does not receive the data, although instead of the variable it gives a fixed text, it does not reach the php.
Thank you very much.