Merge Tag: Blog ID

Read the Walkthrough

Code

Filename: gw-merge-tag-blog-id.php

<?php
/**
 * Gravity Forms // Merge Tag: Blog ID
 * https://gravitywiz.com/s
 */
add_filter( 'gform_pre_replace_merge_tags', function( $text, $form, $lead, $url_encode, $esc_html, $nl2br, $format ) {
	if ( strpos( $text, '{blog_id}' ) !== false ) {
		$text = str_replace( '{blog_id}', get_current_blog_id(), $text );
	}
	return $text;
}, 10, 7 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.