Skip to content

Instantly share code, notes, and snippets.

@girafffee
Last active November 13, 2023 12:07
Show Gist options
  • Save girafffee/eb3a6b5a3afa6fa28733985d5c29320c to your computer and use it in GitHub Desktop.
Save girafffee/eb3a6b5a3afa6fa28733985d5c29320c to your computer and use it in GitHub Desktop.
<?php
add_filter( 'jet-form-builder/render-states', 'custom_jfb_add_states' );
function custom_jfb_add_states( array $states ): array {
class Logged_In_Render_State extends \Jet_Form_Builder\Blocks\Conditional_Block\Render_States\Base_Render_State {
public function get_title(): string {
return 'On user logged in';
}
public function is_supported(): bool {
return is_user_logged_in();
}
public function get_id(): string {
return 'LOGGED.IN';
}
}
class Guest_Render_State extends \Jet_Form_Builder\Blocks\Conditional_Block\Render_States\Base_Render_State {
public function get_title(): string {
return 'On user not logged in';
}
public function is_supported(): bool {
return !is_user_logged_in();
}
public function get_id(): string {
return 'GUEST';
}
}
array_push(
$states,
new Logged_In_Render_State(),
new Guest_Render_State()
);
return $states;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment