Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to accept &uid=whatever and store it into the new donation's uid field.
<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
You can’t perform that action at this time.