Skip to content

Commit

Permalink
Fixed issue with checking for non-existing global option; should be f…
Browse files Browse the repository at this point in the history
…orm meta option rather #551

New param $form_id in give_logged_in_only()
  • Loading branch information
Devin Walker committed Apr 8, 2016
1 parent 3036ffe commit 7e84eff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions assets/js/frontend/give-ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,11 @@ jQuery(document).ready(function ($) {

/**
* Donation Form AJAX Submission
*
*
* @description: Process the donation submit
*/
$('body').on('click touchend', '#give-purchase-button', function (e) {


//this form object
var this_form = $(this).parents('form.give-form');

Expand All @@ -139,9 +138,9 @@ jQuery(document).ready(function ($) {

//HTML5 required check validity
if (typeof give_purchase_form.checkValidity === "function" && give_purchase_form.checkValidity() === false) {

//Don't leave any hanging loading animations
loading_animation.fadeOut();
loading_animation.fadeOut();

//Check for Safari (doesn't support HTML5 required)
if ((navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) === false) {
Expand All @@ -162,6 +161,7 @@ jQuery(document).ready(function ($) {

//Submit form via AJAX
$.post(give_global_vars.ajaxurl, this_form.serialize() + '&action=give_process_checkout&give_ajax=true', function (data) {

if ($.trim(data) == 'success') {
//Remove any errors
this_form.find('.give_errors').remove();
Expand All @@ -174,6 +174,7 @@ jQuery(document).ready(function ($) {
this_form.find('.give_errors').remove();
this_form.find('#give_purchase_submit').before(data);
}

});

});
Expand Down
10 changes: 5 additions & 5 deletions includes/misc-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,17 @@ function give_is_cc_verify_enabled() {


/**
* Checks if users can only give when logged in
* Checks if users can only donate when logged in
*
* @since 1.0
* @global $give_options
* @return bool $ret Whether or not the logged_in_only setting is set
*/
function give_logged_in_only() {
function give_logged_in_only( $form_id ) {

$form_option = get_post_meta( $form_id, '_give_logged_in_only', true );

global $give_options;

$ret = ! empty( $give_options['logged_in_only'] );
$ret = ! empty( $form_option ) ? $form_option : false;

return (bool) apply_filters( 'give_logged_in_only', $ret );

Expand Down

0 comments on commit 7e84eff

Please sign in to comment.