add_cap( 'ALLSI_manage', true ); ALLSI_log( 'Added ALLSI_manage capability to administrator role', 'ACTIVATOR' ); } // Also add capability to current user immediately (in case role update doesn't take effect yet) $current_user = wp_get_current_user(); if ( $current_user && $current_user->ID > 0 ) { $current_user->add_cap( 'ALLSI_manage', true ); ALLSI_log( 'Added ALLSI_manage capability to current user (ID: ' . $current_user->ID . ')', 'ACTIVATOR' ); } // Load rights settings and add capabilities to other roles if configured $options = get_option( 'ALLSI_plugin_rights_settings' ); if ( $options ) { $roles = array( 'editor' => 'rights_editor', 'author' => 'rights_author', 'contributor' => 'rights_contributor', 'subscriber' => 'rights_subscriber', ); foreach ( $roles as $role_name => $option_key ) { $role = get_role( $role_name ); if ( $role && isset( $options[$option_key] ) && $options[$option_key] === 'true' ) { $role->add_cap( 'ALLSI_manage', true ); ALLSI_log( 'Added ALLSI_manage capability to ' . $role_name . ' role', 'ACTIVATOR' ); } } } } }