Jump to content

Colton1070

Member
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Colton1070

  1. Contrary to the defeatist in the comments, there is a solution. However, it requires an upgraded plan with Code Injection. The following script works logically in a couple ways. First, it polls the pop up iframe (accountFrame) and hides the "Create account" button when clicking Log In in the site navigation. This effectively only allows users to log in. Now, users could still manually redirect themselves to the account creation url (/account/login/create), so we also poll for any iframe's with the (account/login/frame/create) src and delete the iframe from existence. Now this would also prevent you from creating accounts so the scripts are conditional. They hide the creation button on all pages except for an admin, password protected, page which allows for account creation. The script which deletes the iframe also only runs on the homepage (as that is the redirect for any manual accessing of the creation url. I hope this helps other lost souls build great community/member only areas. <script> function continuouslyWaitForElement(selector, callback) { if (window.location.href.includes('/create-member-admin')) { console.log('Script execution skipped for this page.'); return; // Exit the function early } let lastElementFound = null; let intervalId = setInterval(() => { const iframe = document.querySelector('#accountFrame'); if (iframe) { const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; const element = iframeDocument.querySelector(selector); if (element && element !== lastElementFound) { callback(element); lastElementFound = element; // Update the last element found } } }, 100); // Check every 100ms } continuouslyWaitForElement('#user-account-login-root > div > div > footer > a:nth-child(2)', function(element) { element.style.display = 'none'; console.log('Element hidden again'); }); function isMainPage() { // Adjust the condition based on your main page's URL return window.location.pathname === '/' || window.location.pathname === '/index.html'; } function pollAndHideIframeBasedOnSrc(iframeSelector, srcToCheck) { if (!isMainPage()) { console.log('Not on the main page, skipping script.'); return; // Exit if not on the main page } const intervalId = setInterval(() => { const iframes = document.querySelectorAll(iframeSelector); iframes.forEach((iframe) => { if (iframe.src.includes(srcToCheck)) { iframe.style.display = 'none'; // Hide the iframe console.log(`Iframe with src ${srcToCheck} was hidden.`); } }); // Consider if you need to clear the interval based on your requirements // For continuous checking, you might leave it running // clearInterval(intervalId); // Uncomment if you want to stop polling after the first check }, 100); // Check every 100ms } pollAndHideIframeBasedOnSrc('#accountFrame', '/account/frame/login/create'); </script>
×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.