Last active
November 13, 2023 12:07
-
-
Save girafffee/eb3a6b5a3afa6fa28733985d5c29320c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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