propertiesToSave as $property) { if ( isset($wp_roles->$property[$id]) ) { $settings[$property] = $wp_roles->$property[$id]; } } if ( !empty($settings) ) { $this->customRoleSettings[$id] = $settings; } } if ( !empty($this->customRoleSettings) ) { add_action('bbp_roles_init', array($this, 'restoreCustomSettings'), $priority + 5); } return $wp_roles; } public function restoreCustomSettings($wp_roles = null) { if ( empty($wp_roles) ) { return $wp_roles; } foreach ($this->customRoleSettings as $id => $properties) { foreach ($properties as $property => $value) { $wp_roles->$property[$id] = $value; } } $this->customRoleSettings = array(); return $wp_roles; } }