plugin/prefill-gravity-forms 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

plugin/prefill-gravity-forms

Composer 安装命令:

composer require plugin/prefill-gravity-forms

包简介

Prefill GravityForms Plugin

README 文档

README

Description

Prefill GravityForms fields, based on the Dutch BSN number. Retrieve personal information and place these values in the corrensponding fields.

Dependencies

To use this plug-in, the following dependencies are required:

  • GravityForms (premium)

In addition, at least one of the following plug-ins must be installed to enable authentication by BSN:

Features

  • Map GravityForms fields to attributes retrieved from the configured supplier.
  • Mapped fields will be prefilled while rendering a form.
  • Gutenberg block for displaying personal data of the current logged in user.

Installation

Manual installation

  1. Upload the 'prefill-gravity-forms' folder in to the /wp-content/plugins/ directory.
  2. cd /wp-content/plugins/prefill-gravity-forms
  3. Run `composer install, NPM asset build is in version control already.
  4. Activate the plugin in via the WordPress admin.

Composer installation

  1. composer source git@github.com:OpenWebconcept/plugin-prefill-gravity-forms.git
  2. composer require plugin/prefill-gravity-forms
  3. cd /wp-content/plugins/prefill-gravity-forms
  4. Run composer install, NPM asset build is in version control already.

Setup

  1. Go to '/wp-admin/admin.php?page=gf_settings&subview=owc-gravityforms-iconnect' and configure all the required settings.
    1. Suppliers will provide the needed certificates which need to be selected in order to make prefilling form fields work.
    1. Suppliers will also provide an API-key, certificates password (if needed) and a base URL.
    1. OIN is a unique number for organizations provided by Logius.
  1. Go to the form settings of the form you want to configure.
  2. Scroll down and look for the 'OWC Prefill' panel and configure the settings.

Cache Encryption

To enable secure caching of sensitive data, you must define an encryption key in your wp-config.php file. This key is used to encrypt and decrypt the cached data and should be kept secret at all times.

Add the following line to your wp-config.php:

// Prefill Gravity Forms – Cache Encryption Key
define('PG_CACHE_ENCRYPTION_KEY', 'your-unique-32-character-key');

Important:

  • Use a randomly generated, 32-character key for strong AES-256 encryption.
  • Never store this key in the database.
  • Keep it secret and secure — anyone with access to this key can decrypt cached data.

License

The source code is made available under the EUPL 1.2 license. Some of the dependencies are licensed differently, with the BSD or MIT license, for example.

User model

The UserModel provides a simple way to access BRP (Basisregistratie Personen) data that has been retrieved after a valid DigiD login. It automatically detects which data supplier is configured (in the add-on settings), loads the correct controller, and exposes a small set of helper methods for use in templates or form-prefill logic.

Before accessing any user attributes, always check whether the user is authenticated using DigiD.

Usage

$user = new \OWC\PrefillGravityForms\Models\UserModel();

if ( $user->isLoggedIn() ) {
    $bsn  = $user->bsn();
    $age  = $user->age();
}

This model does not handle authentication itself, it only exposes data retrieved by the underlying BRP supplier controller. If a controller fails to load (e.g., misconfiguration or missing supplier), the model gracefully returns default values.

To use this model, make sure it is enabled in the settings available at '/wp-admin/admin.php?page=gf_settings&subview=owc-gravityforms-iconnect'. Otherwise, the object will be instantiated but will not contain any data.

Gutenberg blocks

This plugin ships with two Gutenberg blocks for displaying personal data of the logged-in user on any page.

  • Personal Data Table (owc-prefill-gravity-forms/personal-data-table) — a container block that wraps rows in an HTML table (<table>).
  • Personal Data Row (owc-prefill-gravity-forms/personal-data-row) — displays a single personal data field. When placed inside the table block it renders as a <tr>, otherwise as a configurable HTML element (<div>, <p>, or <span>).

Each Personal Data Row block must be configured in the block sidebar:

Setting Description
Supplier Must match the supplier configured in the plugin settings.
Goal binding Required for HaalCentraal API v2 — determines which fields are returned.
Processing Optional processing context for HaalCentraal API v2.
Personal data field The specific BRP attribute to display (e.g. name, date of birth).

Logging

Enable logging to monitor errors during communication with the BRP suppliers.

  • Logs are written daily to pg-log{-date}.json in the WordPress webroot directory.
  • A rotating file handler keeps up to 7 log files by default, deleting the oldest as needed.
  • You can change the maximum number of log files using the filter described below.

Hooks

Change the maximum number of log files

Use the following filter to alter the rotating file handler's max files setting:

apply_filters('pg::logger/rotating_filer_handler_max_files', PG_LOGGER_DEFAULT_MAX_FILES)

Intercept exceptions for custom handling

You can intercept exceptions caught by the plugin for additional processing or custom logging using this filter:

do_action('pg::exception/intercept', $exception, $method)

The $exception parameter contains the caught exception object.

Provide Custom Mapping Options from a Theme Directory

This plugin includes supplier-specific mapping option files. In version 1 of the "HaalCentraal API", all available fields were returned, even when only a subset was needed.

Since version 2 of HaalCentraal, this has changed: the goal binding (doelbinding) now determines which fields are returned. This results in a more concise dataset that contains only the necessary fields. Because each municipality (gemeente) can define its own unique goal bindings and corresponding fields, this plugin cannot include all possible mapping configurations by default.

add_filter('pg::theme/dir_mapping_options', function ($value) {
    return __DIR__ . '/templates/owc-prefill/';
}, 10, 1);

plugin/prefill-gravity-forms 适用场景与选型建议

plugin/prefill-gravity-forms 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 609 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 12 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 plugin/prefill-gravity-forms 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 plugin/prefill-gravity-forms 我们能提供哪些服务?
定制开发 / 二次开发

基于 plugin/prefill-gravity-forms 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 609
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-12-04