Purpose

Modify the payload for the LoadTemplate action, allowing external plugins to adjust the template’s redirect parameters dynamically (e.g., after a button click). The modified payload will be appended as GET parameters to the redirect URL.

Usage

add_filter( 'wr_template_modify_payload', array( $this, 'set_project_id_for_request_button' ), 10, 2 );

Parameters

  • $payload (array): The current payload that will be used for the redirect.
  • $post (mixed): The post or context associated with the template request.

Use Case

This functionality is useful when:

  • You need to include additional parameters (e.g., project_id) in the redirect URL for a specific template.
  • Dynamic adjustments to the template payload are required based on user actions or context.

Implementation Example

add_filter( 'wr_template_modify_payload', array( $this, 'set_project_id_for_request_button' ), 10, 2 );
 
public function set_project_id_for_request_button(  array $payload, $post ): array {
	if ( $payload['template'] === "TemplateIdentifier" ) {
		$payload['project_id'] = 42;
	}
	return $payload;
}