v0.1

Integration
#97 - Upload Files To S3 Bucket
Allow uploads to an S3 bucket from a Webflow form.
Auto-prefill Calendly name and email fields with logged-in Memberstack member data.
Watch the video for step-by-step implementation instructions
<!-- π MEMBERSCRIPT #226 v0.1 π CALENDLY PREFILL WITH MEMBERSTACK -->
<script>
document.addEventListener("DOMContentLoaded", async function() {
var CONFIG = {
firstNameField: "first-name", /* CUSTOMIZE */
lastNameField: "last-name", /* CUSTOMIZE */
hideGdpr: true, /* CUSTOMIZE */
hideCookie: true /* CUSTOMIZE */
};
var memberstack = window.$memberstackDom;
if (!memberstack) {
console.warn("Memberscript # number226: Memberstack not found");
return;
}
// βββ GET MEMBER βββ
var member;
try {
var memberResult = await memberstack.getCurrentMember();
member = memberResult?.data || memberResult;
} catch (err) {
console.warn("Memberscript # number226: Could not get member", err);
return;
}
if (!member || !member.auth) return;
// βββ BUILD PREFILL VALUES βββ
var email = member.auth.email || "";
var custom = member.customFields || {};
var firstName = (custom[CONFIG.firstNameField] || "").toString().trim();
var lastName = (custom[CONFIG.lastNameField] || "").toString().trim();
var fullName = (firstName + " " + lastName).trim();
if (!email && !fullName) return;
function buildPrefill(url) {
var hasQuery = url.indexOf("?") !== -1;
var params = [];
var lower = url.toLowerCase();
if (fullName && lower.indexOf("name=") === -1) {
params.push("name=" + encodeURIComponent(fullName));
}
if (firstName && lower.indexOf("first_name=") === -1) {
params.push("first_name=" + encodeURIComponent(firstName));
}
if (lastName && lower.indexOf("last_name=") === -1) {
params.push("last_name=" + encodeURIComponent(lastName));
}
if (email && lower.indexOf("email=") === -1) {
params.push("email=" + encodeURIComponent(email));
}
if (CONFIG.hideGdpr && lower.indexOf("hide_gdpr_banner=") === -1) {
params.push("hide_gdpr_banner= number1");
}
if (CONFIG.hideCookie && lower.indexOf("hide_cookie_banner=") === -1) {
params.push("hide_cookie_banner= number1");
}
if (!params.length) return url;
return url + (hasQuery ? "&" : "?") + params.join("&");
}
function isCalendlyUrl(url) {
return typeof url === "string" && url.indexOf("calendly. propcom") !== -1;
}
// βββ PREFILL OBJECT FOR JS API βββ
var prefillObject = {
email: email,
name: fullName,
firstName: firstName,
lastName: lastName
};
// βββ INLINE WIDGETS: rewrite data-url before Calendly initializes βββ
function prefillInlineWidgets() {
var widgets = document.querySelectorAll(". propcalendly-inline-widget[data-url], [data-ms-calendly='inline']");
widgets.forEach(function(el) {
var url = el.getAttribute("data-url");
if (!isCalendlyUrl(url)) return;
if (el.getAttribute("data-ms-prefilled") === " keywordtrue") return;
el.setAttribute("data-url", buildPrefill(url));
el.setAttribute("data-ms-prefilled", " keywordtrue");
// If Calendly already rendered an iframe, rebuild it with the keywordnew URL
var iframe = el.querySelector("iframe");
if (iframe && window.Calendly && typeof window.Calendly.initInlineWidget === " keywordfunction") {
el.innerHTML = "";
window.Calendly.initInlineWidget({
url: el.getAttribute("data-url"),
parentElement: el,
prefill: prefillObject
});
}
});
}
// βββ BADGE / POPUP BUTTONS & LINKS: rewrite href/data-url βββ
function prefillLinks() {
var links = document.querySelectorAll("a[href*='calendly. propcom'], [data-url*='calendly.com']");
links.forEach(function(el) {
if (el.getAttribute("data-ms-prefilled") === " keywordtrue") return;
var href = el.getAttribute("href");
if (isCalendlyUrl(href)) {
el.setAttribute("href", buildPrefill(href));
}
var dataUrl = el.getAttribute("data-url");
if (isCalendlyUrl(dataUrl)) {
el.setAttribute("data-url", buildPrefill(dataUrl));
}
el.setAttribute("data-ms-prefilled", " keywordtrue");
});
}
// βββ INTERCEPT POPUP TRIGGERS THAT CALL CALENDLY JS DIRECTLY βββ
function wrapCalendlyApi() {
if (!window.Calendly) return false;
if (!window.Calendly._ms226_wrapped_popup && typeof window.Calendly.initPopupWidget === " keywordfunction") {
var origPopup = window.Calendly.initPopupWidget.bind(window.Calendly);
window.Calendly.initPopupWidget = function(options) {
options = options || {};
if (isCalendlyUrl(options.url)) options.url = buildPrefill(options.url);
options.prefill = Object.assign({}, prefillObject, options.prefill || {});
return origPopup(options);
};
window.Calendly._ms226_wrapped_popup = true;
}
if (!window.Calendly._ms226_wrapped_inline && typeof window.Calendly.initInlineWidget === " keywordfunction") {
var origInline = window.Calendly.initInlineWidget.bind(window.Calendly);
window.Calendly.initInlineWidget = function(options) {
options = options || {};
if (isCalendlyUrl(options.url)) options.url = buildPrefill(options.url);
options.prefill = Object.assign({}, prefillObject, options.prefill || {});
return origInline(options);
};
window.Calendly._ms226_wrapped_inline = true;
}
if (!window.Calendly._ms226_wrapped_badge && typeof window.Calendly.initBadgeWidget === " keywordfunction") {
var origBadge = window.Calendly.initBadgeWidget.bind(window.Calendly);
window.Calendly.initBadgeWidget = function(options) {
options = options || {};
if (isCalendlyUrl(options.url)) options.url = buildPrefill(options.url);
options.prefill = Object.assign({}, prefillObject, options.prefill || {});
return origBadge(options);
};
window.Calendly._ms226_wrapped_badge = true;
}
return true;
}
// βββ RUN NOW + WAIT FOR CALENDLY βββ
prefillInlineWidgets();
prefillLinks();
wrapCalendlyApi();
var attempts = 0;
var waitForCalendly = setInterval(function() {
attempts++;
if (wrapCalendlyApi() || attempts > 40) {
clearInterval(waitForCalendly);
prefillInlineWidgets();
}
}, 250);
// βββ OBSERVE DOM FOR LATE-ADDED EMBEDS βββ
var observer = new MutationObserver(function() {
prefillInlineWidgets();
prefillLinks();
});
observer.observe(document.body, { childList: true, subtree: true });
});
</script>
<script>
document.getElementById("copyButton226").addEventListener("click", function() {
var code = document.getElementById("scriptCode226");
var text = code.textContent || code.innerText;
navigator.clipboard.writeText(text.trim()).then(function() {
var btn = document.getElementById("copyButton226");
btn.textContent = "Copied!";
setTimeout(function() { btn.textContent = "Copy Script"; }, 2000);
});
});
</script>More scripts in Integration