User-specific Sessions

Make Nested Forms sessions specific to the currently logged in user by appending the current User ID.

Instructions

See “Where do I put snippets?” in our documentation for installation instructions.

Code

Filename: gpnf-user-specific-sessions.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
/**
 * Gravity Perks // Nested Forms // User-specific Sessions
 * https://gravitywiz.com/documentation/gravity-forms-nested-forms/
 *
 * Make Nested Forms sessions specific to the currently logged in user by appending the current User ID.
 */
add_filter( 'gpnf_cookie_name', function ( $name, $form_id ) {

	// Get the current User ID.
	$id = get_current_user_id();

	if ( $id ) {
		$name = sprintf( '%s_%s', $name, $id );
	}

	return $name;
}, 10, 2 );

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.