gcn_notion_page_data

  1. Description
  2. Usage
  3. Parameters
  4. Since
  5. Examples
    1. Disable updating Notion page content
    2. Support Notion’s Relation Property

Description

Filters the values to be added to the page.

Usage

Apply when adding and updating Notion pages on all forms on all feeds.

add_filter( 'gcn_notion_page_data', 'my_custom_function' );

Apply only when adding Notion pages on all forms on all feeds.

add_filter( 'gcn_notion_page_data_add', 'my_custom_function' );

Apply only when updating Notion pages on all forms on all feeds.

add_filter( 'gcn_notion_page_data_update', 'my_custom_function' );

Apply only when adding Notion pages on a specific forms on all feeds.

add_filter( 'gcn_notion_page_data_add_{form_id}', 'my_custom_function' );

Apply only when updating Notion pages on a specific forms on all feeds.

add_filter( 'gcn_notion_page_data_update_{form_id}', 'my_custom_function' );

Apply only when adding Notion pages on a specific forms on a specific feed.

add_filter( 'gcn_notion_page_data_add_{form_id}_{feed_id}', 'my_custom_function' );

Apply only when updating Notion pages on a specific forms on a specific feed.

add_filter( 'gcn_notion_page_data_update_{form_id}_{feed_id}', 'my_custom_function' );

Parameters

  • page_data array

    The values to be updated on the Notion page.

    • properties array

      An associative array of property values to be updated in Notion. Each key in the array corresponds to a property name in Notion, and the value is structured according to the Notion API’s requirements for that property type. These properties must conform what is defined in the Notion API database property documentation.

    • cover array

      An array structured according to the Notion API’s requirements to define the cover image of the page. This must conform to what is defined in the Notion API “file object” documentation.

    • children array An array structured according to the Notion API’s requirements for to define the page content or “blocks” added to the Notion Page. These must conform to the Notion block object API.

  • form array

    The form being used.

  • entry array

    The entry being updated.

  • feed array

    The feed being used.

Since

This filter is available since Gravity Connect Notion 1.0.0.

Examples

Disable updating Notion page content

Disable page content in Notion from getting updated/deleted when an entry is edited.

add_filter( 'gcn_notion_page_data_update', 'gcn_skip_page_content_update', 10, 4 );

function gcn_skip_page_content_update( $page_data, $form, $entry, $feed ) {
    $page_data['children'] = null;
    return $page_data;
}

Support Notion’s Relation Property

Add a page relation when a page is created in Notion

add_filter( 'gcn_notion_page_data', 'gcn_add_relation_property', 10, 4 );

function gcn_add_relation_property( $page_data, $form, $entry, $feed ) {
    $page_id = 'NOTION_PAGE_ID'; // the id of the page you want to create a relation to.
    $prop_name = 'Test Relation';
    $prop_type = 'relation';

    $page_data['properties'][ $prop_name ] = array(
        $prop_type => array(
            array(
                'id' => $page_id,
            ),
        ),
    );
}