When having a custom dashboard set using BricksForge > Backend Designer, the dashboard is showing the homepage for users with non-admin role.
We created this script to fix the issue, but we would like to see this solved in a new BricksForge release:
add_action('admin_head-index.php', function () {
// user role
if (!current_user_can('editor') && !in_array('sb_office', wp_get_current_user()->roles)) {
return;
}
echo '<style>#wpbody-content { display: none; }</style>';
});
add_action('admin_footer-index.php', function () {
// User role
if (!current_user_can('editor') && !in_array('sb_office', wp_get_current_user()->roles)) {
return;
}
// Change template id.
$template_id = 20932;
$template_url = get_permalink($template_id) . '?backend=true';
?>
<script>
document.addEventListener('DOMContentLoaded', function () {
const wpBodyContent = document.getElementById('wpbody-content');
if (wpBodyContent) {
wpBodyContent.innerHTML = `
<iframe
src="<?php echo esc_url($template_url); ?>"
style="
border: none;
bottom: 0;
height: calc(100vh - 32px);
left: 0;
margin-left: 160px;
margin-top: 32px;
overflow: hidden;
position: fixed;
right: 0;
top: 0;
width: calc(100vw - 160px);
"
frameborder="0"
scrolling="auto"
></iframe>
`;
wpBodyContent.style.display = 'block';
}
});
</script>
<?php
});