Set Blocklist by Field Value

Video Instructions: https://www.loom.com/share/95b7192628774a3ebd0a0f47a4acd50a

Use this snippet to create a blocklist editor form. We recommend using Populate Anything to populate WordPress’ current blocklist into the field. The user can then edit the values and submit the form. This snippet will handle updating the blocklist option in the database.

Code

Filename: gpb-set-blocklist-by-field-value.php

<?php
/**
 * Gravity Perks // Blocklist // Set Blocklist by Field Value
 * https://gravitywiz.com/documentation/gravity-forms-blocklist/
 *
 * Video Instructions: https://www.loom.com/share/95b7192628774a3ebd0a0f47a4acd50a
 *
 * Use this snippet to create a blocklist editor form. We recommend using [Populate Anything][1] to
 * populate WordPress' current blocklist into the field. The user can then edit the values and submit
 * the form. This snippet will handle updating the blocklist option in the database.
 *
 * [1]: https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 */
// Update "123" to your form ID.
add_action( 'gform_after_submission_123', function( $entry, $form ) {
	// Update "4" to the field ID whose value should be used to set the blocklist.
	update_option( 'disallowed_keys', rgar( $entry, 4 ) );
}, 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.