feat: Improve dashboard navigation for Master Trainers
- Add Master Dashboard button to trainer dashboard for users with master trainer capabilities - Change "Your Dashboard" to "Trainer Dashboard" in master dashboard for clearer navigation - Update login redirection logic to prioritize Master Trainers (redirect to master-dashboard first) - Enhance cross-navigation between dashboards based on user permissions Files modified: - templates/template-hvac-dashboard.php: Added conditional Master Dashboard button - templates/template-hvac-master-dashboard.php: Updated button text for clarity - includes/community/class-login-handler.php: Enhanced login redirect logic 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
cb45406a9e
commit
b7dfde141f
3 changed files with 23 additions and 6 deletions
|
|
@ -169,9 +169,15 @@ class Login_Handler {
|
|||
public function custom_login_redirect( $redirect_to, $requested_redirect_to, $user ) {
|
||||
// Check if login was successful and user is not an error object
|
||||
if ( $user && ! is_wp_error( $user ) ) {
|
||||
// Check if the user has Master Trainer capabilities - redirect to Master Dashboard first
|
||||
if ( user_can( $user, 'view_master_dashboard' ) || user_can( $user, 'view_all_trainer_data' ) ) {
|
||||
// Redirect Master Trainers to the Master Dashboard
|
||||
$master_dashboard_url = home_url( '/master-dashboard/' );
|
||||
return $master_dashboard_url;
|
||||
}
|
||||
// Check if the user has the 'hvac_trainer' role
|
||||
if ( in_array( 'hvac_trainer', (array) $user->roles ) ) {
|
||||
// Redirect HVAC trainers to their dashboard
|
||||
elseif ( in_array( 'hvac_trainer', (array) $user->roles ) ) {
|
||||
// Redirect regular HVAC trainers to their dashboard
|
||||
// Assumes dashboard page slug is 'hvac-dashboard'. Adjust if needed.
|
||||
$dashboard_url = home_url( '/hvac-dashboard/' );
|
||||
return $dashboard_url;
|
||||
|
|
@ -197,9 +203,14 @@ class Login_Handler {
|
|||
// Get current user
|
||||
$user = wp_get_current_user();
|
||||
|
||||
// Redirect based on user role/capabilities
|
||||
if ( in_array( 'hvac_trainer', (array) $user->roles ) || current_user_can( 'view_hvac_dashboard' ) ) {
|
||||
// HVAC trainers go to their dashboard
|
||||
// Redirect based on user role/capabilities - prioritize Master Trainers
|
||||
if ( current_user_can( 'view_master_dashboard' ) || current_user_can( 'view_all_trainer_data' ) ) {
|
||||
// Master Trainers go to the Master Dashboard
|
||||
$master_dashboard_url = home_url( '/master-dashboard/' );
|
||||
wp_safe_redirect( $master_dashboard_url );
|
||||
exit;
|
||||
} elseif ( in_array( 'hvac_trainer', (array) $user->roles ) || current_user_can( 'view_hvac_dashboard' ) ) {
|
||||
// Regular HVAC trainers go to their dashboard
|
||||
$dashboard_url = home_url( '/hvac-dashboard/' );
|
||||
wp_safe_redirect( $dashboard_url );
|
||||
exit;
|
||||
|
|
|
|||
|
|
@ -123,6 +123,12 @@ get_header(); // Use theme's header
|
|||
'<a href="' . esc_url( home_url( '/trainer-profile/' ) ) . '" class="ast-button ast-button-secondary">View Profile</a>',
|
||||
'Update your professional credentials, business information, and training specialties'
|
||||
); ?>
|
||||
<?php if ( current_user_can( 'view_master_dashboard' ) || current_user_can( 'view_all_trainer_data' ) ): ?>
|
||||
<?php echo HVAC_Help_System::add_tooltip(
|
||||
'<a href="' . esc_url( home_url( '/master-dashboard/' ) ) . '" class="ast-button ast-button-primary">Master Dashboard</a>',
|
||||
'Access the Master Trainer Dashboard to view system-wide analytics and manage all trainers'
|
||||
); ?>
|
||||
<?php endif; ?>
|
||||
<a href="<?php echo esc_url( home_url( '/hvac-documentation/' ) ); ?>" class="ast-button ast-button-secondary">Help</a>
|
||||
<a href="<?php echo esc_url( wp_logout_url( home_url( '/community-login/' ) ) ); ?>" class="ast-button ast-button-secondary">Logout</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ if ( isset( $_GET['error'] ) && $_GET['error'] === 'access_denied' ) {
|
|||
<?php if (current_user_can('manage_communication_templates')): ?>
|
||||
<a href="<?php echo home_url('/communication-templates/'); ?>" class="ast-button ast-button-primary">Templates</a>
|
||||
<?php endif; ?>
|
||||
<a href="<?php echo home_url('/hvac-dashboard/'); ?>" class="ast-button ast-button-secondary">Your Dashboard</a>
|
||||
<a href="<?php echo home_url('/hvac-dashboard/'); ?>" class="ast-button ast-button-secondary">Trainer Dashboard</a>
|
||||
<a href="<?php echo esc_url( wp_logout_url( home_url( '/community-login/' ) ) ); ?>" class="ast-button ast-button-secondary">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue