Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1473370

    Hi.
    I have a few different user Roles and I want to hide certain elements on the homepage based on the Role.

    Have a look at the Home page. When I log in as a certain user, the elements are hidden, but the spaces are left where they were, making the layout have gaps all over where the elements have been removed.

    The following is what I have tried, but I am not sure if I am targeting the correct elements.

    JavaScript:
    document.addEventListener(“DOMContentLoaded”, function () {
    console.log(“Custom.js is running”);
    console.log(“User Data:”, userData);

    const userRole = userData.role.toLowerCase(); // Convert role to lowercase for comparison
    console.log(“User Role:”, userRole);

    if (userRole === “mrpi_user”) {
    console.log(“Role matches MRPI User. Waiting for elements to load…”);

    const interval = setInterval(function () {
    // Specify the elements to remove
    const elementsToRemove = [
    document.getElementById(“Wholesaler_Element_Homepage”),
    document.getElementById(“Products_Element_Homepage”),
    ];

    let allElementsFound = true;

    // Loop through the elements to remove
    elementsToRemove.forEach(function (element) {
    if (element) {
    console.log(“Removing element:”, element);
    element.remove(); // Remove the specific element
    } else {
    console.log(“Element not found yet.”);
    allElementsFound = false; // Keep checking if any element is not found
    }
    });

    // Stop checking when all elements are removed
    if (allElementsFound) {
    clearInterval(interval);
    }
    }, 100); // Check every 100ms
    } else {
    console.log(“Role does not match. Skipping element removal.”);
    }
    });

    CSS:

    #av_section_2 {
    display: flex; /* Enable flexbox layout */
    flex-wrap: wrap; /* Allow items to wrap to the next row if necessary */
    justify-content: flex-start; /* Align items to the left */
    padding: 0; /* Remove internal padding */
    margin: 0; /* Remove external margins */
    height: auto; /* Adjust height dynamically */
    gap: 10px; /* Optional: Add spacing between items */
    }

    #av_section_2 > .flex_column {
    flex: 1 1 auto; /* Allow items to grow and shrink dynamically */
    margin: 0; /* Remove margin between elements */
    padding: 0; /* Remove internal padding */
    }

    HTML:
    <div id=”Wholesaler_Element_Homepage”></div>
    <div id=”Products_Element_Homepage”></div>

    #1473387

    Hey Nick_Skehan,

    Thank you for the inquiry.

    Where do you get the userData? We can help you with minor modifications to the theme, but the behavior or feature you’re after seems a bit beyond the scope of support. You may need to hire a freelance developer or contact our partner, Codeable. Please check the link below: https://kriesi.at/contact/customization

    Best regards,
    Ismael

    #1473426

    Thanks, Ismael.

    Perhaps I am not explaining myself or maybe overexplained!; when an item is hidden on a page, how do I prevent there being blank white spaces where the hidden item has been removed?

    What I would like is for the other elements to flow into the empty white spaces. This is the CSS I have tried, but the spaces are not being filled out.

    CSS:

    #av_section_2 {
    display: flex; /* Enable flexbox layout */
    flex-wrap: wrap; /* Allow items to wrap to the next row if necessary */
    justify-content: flex-start; /* Align items to the left */
    padding: 0; /* Remove internal padding */
    margin: 0; /* Remove external margins */
    height: auto; /* Adjust height dynamically */
    gap: 10px; /* Optional: Add spacing between items */
    }

    #av_section_2 > .flex_column {
    flex: 1 1 auto; /* Allow items to grow and shrink dynamically */
    margin: 0; /* Remove margin between elements */
    padding: 0; /* Remove internal padding */
    }

    #1473461

    Hi,

    Thank you for the update.

    We can’t login using any of the account above. Please check the info carefully. Would you mind providing a screenshot of the issue? You can use platforms like Savvyify, Imgur or Dropbox to upload and share the screenshot. Here are the steps to follow:

    1.) Visit the website of your chosen platform, such as Savvyify, Imgur or Dropbox.
    2.) Locate the option to upload a file or an image.
    3.) Select the screenshot file from your computer or device and upload it to the platform.
    4.) After the upload is complete, you will be provided with a shareable link or an embed code.
    5.) Copy the link or code and include it in your message or response to provide us with the screenshot.

    Thank you for taking the time to share the screenshot. It will help us better understand the issue you’re facing and provide appropriate assistance.

    Best regards,
    Ismael

    #1473475

    Thanks for your help Ismael.

    Here are two screen grabs. User A has full access. User B has some hidden content, but the hidden elements are still holding blank spaces.

    https://img.savvyify.com/image/User-B-empty-spaces.9xktO
    https://img.savvyify.com/image/User-A-Full-Access.9xIYz

    Thanks
    Nick

    • This reply was modified 1 week, 2 days ago by Nick_Skehan. Reason: Typo
    #1473533

    Hi,

    Thank you for the screenshots.

    How are you hiding the content? It’s possible that only the content are hidden and the column wrappers or containers are still present, causing the gap. In your script above, you may need to locate the parent container (the column element) of the filtered content and remove it.

    Best regards,
    Ismael

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.