Created
February 10, 2016 22:34
-
-
Save salsalabs/59471d0b796a6002abea to your computer and use it in GitHub Desktop.
Script to accept &uid=whatever and store it into the new donation's uid field.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
// Add donation.uid to the form and populate it with the contents of the | |
// `uid` query in the URL. | |
// @see https://salsasupport.zendesk.com/entries/98784548 | |
$(document).ready(function() { | |
if (window.location.href.indexOf('public/?donate_page_KEY=') == -1) { | |
return; | |
} | |
var searches = window.location.search.split('&') | |
.reduce(function(a, x) { | |
var parts = x.split('='); | |
a[parts[0]] = (parts.length > 1) ? parts.splice(1).join('=') : null; | |
return a; | |
}, {}); | |
if (searches.hasOwnProperty('uid')) { | |
// @note The UID *must* appear at the end of the form. If it's not there | |
// then Salsa will apply it to the supporter record. | |
$('form[name=subform]').append('' | |
+ '<input type="hidden" name="object" value="donation"/>' | |
+ '<input type="hidden" name="uid" value="' + searches['uid'] + '"/>'); | |
}; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment