Using Gravity Forms ‘gform_embed_edit_post_link’ PHP action

The gform_embed_edit_post_link Gravity Forms PHP filter is used to customize the edit post link template for the Embed Form flyout.

Usage

A generic example of how to use the filter:

add_filter('gform_embed_edit_post_link', 'your_function_name');

Parameters

  • $edit_link (string): The edit link. Use %1$s as the placeholder for the page/post ID.

Example:

$edit_link = 'https://example.com/wp-admin/post.php?post=%1$s&action=edit';

More information

See Gravity Forms Docs: gform_embed_edit_post_link

Examples

Change the page and post query argument name

A detailed explanation of what the code does: This example changes the page and post query argument name in the edit link.

add_filter('gform_embed_edit_post_link', function($edit_link) {
    $edit_link = str_replace('post.php?post=', 'custom-page.php?something=', $edit_link);
    return $edit_link;
});

Add an additional query parameter

A detailed explanation of what the code does: This example adds an additional query parameter to the edit link.

add_filter('gform_embed_edit_post_link', function($edit_link) {
    $edit_link = $edit_link . '&additional_param=value';
    return $edit_link;
});

Modify the action parameter

A detailed explanation of what the code does: This example modifies the action parameter in the edit link.

add_filter('gform_embed_edit_post_link', function($edit_link) {
    $edit_link = str_replace('action=edit', 'action=custom_action', $edit_link);
    return $edit_link;
});

A detailed explanation of what the code does: This example changes the edit link to a custom URL.

add_filter('gform_embed_edit_post_link', function($edit_link) {
    $edit_link = 'https://example.com/custom-url?post=%1$s';
    return $edit_link;
});

A detailed explanation of what the code does: This example conditionally modifies the edit link based on the post type.

add_filter('gform_embed_edit_post_link', function($edit_link) {
    $post_type = get_post_type();
    if ($post_type === 'custom_post_type') {
        $edit_link = 'https://example.com/custom-url?post=%1$s';
    }
    return $edit_link;
});