David Bravo
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] Relational dropdown option valueHi grigaswp!
That is EXACTLY what I was looking for. I was starting to think that this feature didn’t exist in any plugin, though I guess it is not that uncommon for a lot of selling products.
Thanks a lot, I’m telling my client right now!
Cheers!
I think I’ve finally figured it out. It seems that, at least this site (server or whatever) doesn’t work with the html5 uploader. I’ve changed it to the “standard” uploader and files appear where they should, so if someone else experiments this kind of problem, he/she can try that.
Thanks!Hello!
Well, I’ve installed a local version of the same site locally and it does work, so I think you’re right and it may have something to do with a plugin, maybe a capabilities (custom users) problem.
Thanks anyway for your time!
If you wish, I can write what was happening when I fix it, so any other user may find the solution to this problem.I’ve checked the code, and there’s a typo:
In javascript code, this line:
if (!sendrForm) {
should be
if (!sendForm) {
and also, at the end of that validate.js file, you also need the field validation functions:
function newsletter_check_field(field, message) { if (!field) return true; if (field.type == "checkbox" && !field.checked) { alert(message); return false; } if (field.required !== undefined && field.required !== false && field.value == ""){ alert(message); return false; } return true; } function newsletter_check(f) { var re = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-]{1,})+\.)+([a-zA-Z0-9]{2,})+$/; if (!re.test(f.elements["ne"].value)) { alert(newsletter.messages.email_error); return false; } if (!newsletter_check_field(f.elements["nn"], newsletter.messages.name_error)) return false; if (!newsletter_check_field(f.elements["ns"], newsletter.messages.surname_error)) return false; for (var i = 1; i < newsletter.profile_max; i++) { if (!newsletter_check_field(f.elements["np" + i], newsletter.messages.profile_error)) return false; } if (!newsletter_check_field(f.elements["ny"], newsletter.messages.privacy_error)) return false; return true; }
if not, it will throw a javascript error. As this functions where already there, I took it for granted that you’ll have left them there.
I can’t remember having changed any more code, so maybe with echos and console.logs you can check out where the code is failing. I can assure that in my site works.
And for my client, the functionality is clear: only new subscribers to the whole site will recieve a coupon with a discount, so the first time, they have this coupon. The second time they try, the system alerts that they are already subscribed and there’s no new coupon for them. ??
Hi! Well, if that’s possible, I couldn’t figure out how to do it. I mean overriding Newsletter’s own js file. I tried replicating the structure with no luck, so as my client was in a hurry, I left it like that. You know, low budget, no time left to invest. ??
Maybe you may find out how and that way the plugin would be updateable. (though I made another modification so I’ll keep it out of the updatability). ??
Don’t know anything about emails either. Sorry.With a bit of tweaking, I finaly managed to fix it.
In my theme’s function.php file:
add_action('wp_head', 'pluginname_ajaxurl'); //needed to pass AJAX path for NEWSLETTER plugin modification (see below)function pluginname_ajaxurl() {
?>
<script type="text/javascript">
var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
</script>
<?php
}function check_mail_THEME() {
// The $_REQUEST contains all the data sent via ajax
if (isset($_REQUEST)) {$mail = $_REQUEST['mail'];
global $wpdb;
$query = $wpdb->prepare("SELECT status FROM wp_newsletter WHERE email = %s", $mail);
$status = $wpdb->get_var($query);echo $status;
wp_die(); // Always die in functions echoing ajax content
}
}add_action('wp_ajax_nopriv_check_mail_THEME', 'check_mail_THEME');
add_action('wp_ajax_check_mail_THEME', 'check_mail_THEME');
and then in validate.js file in Newsletter plugin “subscription” folder:
// this code at the top
jQuery(document).ready(function ($) {
var myForm = $('form#newsletterForm');
var sendForm = false;
myForm.submit(function (e) {
if (!sendrForm) {
e.preventDefault();
}if (newsletter_check(this)) { // First I check fields
var myMail = this.elements["ne"].value;
$.ajax({// This does the ajax request
url: ajaxurl,
data: {
action: "check_mail_THEME",
mail: myMail
},
type: "POST",
success: function (data) {
if (!data) { // everything OK
sendForm = true;
myForm.submit();
} else {
switch (data) {
case 'S': // already registered but not confirmed
alert('Sorry, already registered but not confirmed');
break;
case 'C': // Fully registered
alert('Sorry, mail already registered');
break;
}
return false;
}
},
error: function (errorThrown) {
console.log(errorThrown);
return false;
}
});
}
});
});
Obviously you won’t be able to update the plugin as one of its core files is been modified.
With a bit of tweaking, I finaly managed to fix it.
In my theme’s function.php file:
add_action('wp_head', 'pluginname_ajaxurl'); //needed to pass AJAX path for NEWSLETTER plugin modification (see below)function pluginname_ajaxurl() {
?>
<script type="text/javascript">
var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
</script>
<?php
}function check_mail_THEME() {
// The $_REQUEST contains all the data sent via ajax
if (isset($_REQUEST)) {$mail = $_REQUEST['mail'];
global $wpdb;
$query = $wpdb->prepare("SELECT status FROM wp_newsletter WHERE email = %s", $mail);
$status = $wpdb->get_var($query);echo $status;
wp_die(); // Always die in functions echoing ajax content
}
}add_action('wp_ajax_nopriv_check_mail_THEME', 'check_mail_THEME');
add_action('wp_ajax_check_mail_THEME', 'check_mail_THEME');
and then in validate.js file in Newsletter plugin “subscription” folder:
// this code at the top
jQuery(document).ready(function ($) {
var myForm = $('form#newsletterForm');
var sendForm = false;
myForm.submit(function (e) {
if (!sendrForm) {
e.preventDefault();
}if (newsletter_check(this)) { // First I check fields
var myMail = this.elements["ne"].value;
$.ajax({// This does the ajax request
url: ajaxurl,
data: {
action: "check_mail_THEME",
correo: myMail
},
type: "POST",
success: function (data) {
if (!data) { // everything OK
sendForm = true;
myForm.submit();
} else {
switch (data) {
case 'S': // already registered but not confirmed
alert('Sorry, already registered but not confirmed');
break;
case 'C': // Fully registered
alert('Sorry, mail already registered');
break;
}
return false;
}
},
error: function (errorThrown) {
console.log(errorThrown);
return false;
}
});
}
});
});
Obviously you won’t be able to update the plugin as one of its core files is been modified.
Hi Stefano.
Well, I finally changed the functionality of it, as my client wanted. I know that it’s a bit strange but they only needed to be registered once, as they are making coupons offers just for the new subscribers, so I had no other choice.Thanks!
Forum: Plugins
In reply to: [Newsletter - Send awesome emails from WordPress] This email already existsThanks Stefano:
I could finally implement it myself, as my client needed to have only one email registered. They are using this subscription plugin to prepare coupon campaings where a user can only register once. I know that maybe this is not the right plugin to do that, but still. If you wish, I can send you the code where I achieved this so you can make it an option for your plugin. ??Forum: Plugins
In reply to: [Newsletter - Send awesome emails from WordPress] This email already existsWas this feature finally included? I’m having trouble with this as my client wants just one email to be subscribed to their only newsletter. Actually, they are using the plugin just to register user that later will be exported to, and then imported into Mailchimp.
Did you find a solution for this? I’m having the same problem now. I could tweak the code but maybe has something to do with any custom preference? ??
?Did you find a solution for this? I’m having the same problem now.
Forum: Plugins
In reply to: [CMB2] Error from async-upload.php – redirect 302 – with SSL enabledMmmm, that looks promising. But I had my users to be logged via back-end login (though customized).
Maybe something has changed since last summer as my development is now severals months old.I definitely will give that a try. Regards Vicente! (from Spain too? I’m from Madrid) ??
And thanks to Michael for his great work.Forum: Plugins
In reply to: [CMB2] Error from async-upload.php – redirect 302 – with SSL enabledI don’t think so. I think it has definetively something to do with user privileges. If the logged user is an “admin”, there’s no problem at all (nor that I recall). But if the user is a “subscriber”, the same error happened. I don’t have the time to try newer updates, and my client gave up on using ssl, so maybe in a near future I’ll give it a try.
@vicentemanzano84 could make it work because he was identifying (as admin, I guess) so it’s the same case than me.