I'm getting the below error when I browse the following URL:
http://127.0.0.1/mywebsite/customer/account/create
1 exception(s): Exception #0 (Exception): Notice: Undefined variable: customergroupid in /var/www/html/mywebsite/app/design/frontend/Module/vendor/Magento_CustomerCustomAttributes/templates/form/userattributes.phtml on line 27
I have checked the path and see I have below code:
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php
/**
* Create account form template
*
* @see \Magento\CustomerCustomAttributes\Block\Form
*/
/* @var $block \Magento\CustomerCustomAttributes\Block\Form */
?>
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->create('Magento\Customer\Model\Session');
if ($customerSession->isLoggedIn()) {
$customergroupid = $customerSession->getCustomer()->getGroupId();
//echo $customergroupid;
}
?>
<?php if(($customergroupid == 4) || ($customergroupid == 5) || ($customergroupid == 6)): ?>
<?php if ($block->hasUserDefinedAttributes()): ?>
<?php if ($block->isShowContainer()): ?>
<fieldset class="fieldset">
<?php endif;?>
<?php foreach ($block->getUserDefinedAttributes() as $attribute):?>
<?php $attributeContent = $block->getAttributeHtml($attribute);?>
<?php if ($attributeContent): ?>
<?= /* @escapeNotVerified */ $attributeContent ?>
<?php endif;?>
<?php endforeach;?>
<?php if ($block->isShowContainer()): ?>
</fieldset>
<?php endif;?>
<?php endif; ?>
<?php endif; ?>
How can I resolve this issue?
Your help will be greatly appreciated!