diff --git a/frappe/utils/user.py b/frappe/utils/user.py index a3cd923a7e..558ce6fff1 100644 --- a/frappe/utils/user.py +++ b/frappe/utils/user.py @@ -441,3 +441,21 @@ def get_users_with_role(role: str) -> list[str]: .distinct() .run(pluck=True) ) + + +def is_portal_user(): + from frappe.utils import has_common + + roles = get_portal_roles() + user_type = frappe.session.data.user_type + if user_type == "Website User" and has_common(frappe.get_roles(), roles): + return True + + +def get_portal_roles(): + roles = [] + for menu_item in frappe.get_single("Portal Settings").menu: + if menu_item.role and menu_item.role not in roles: + roles.append(menu_item.role) + + return roles diff --git a/frappe/website/utils.py b/frappe/website/utils.py index 1118bec946..62e18143f9 100644 --- a/frappe/website/utils.py +++ b/frappe/website/utils.py @@ -20,6 +20,7 @@ from frappe.utils import ( get_system_timezone, md_to_html, ) +from frappe.utils.user import is_portal_user FRONTMATTER_PATTERN = re.compile(r"^\s*(?:---|\+\+\+)(.*?)(?:---|\+\+\+)\s*(.+)$", re.S | re.M) H1_TAG_PATTERN = re.compile("
{{ introduction }}