Skip to content

Instantly share code, notes, and snippets.

View girafffee's full-sized avatar
Not just learning...

Sasha Ivanenko girafffee

Not just learning...
View GitHub Profile
@girafffee
girafffee / jet-form-builder-eye-icon.css
Last active April 16, 2024 00:10
Eye icon for password input (JetFormBuilder) with Dashicons (https://developer.wordpress.org/resource/dashicons/)
.jet-form-builder__field-wrap input.eye-icon + .dashicons {
position: absolute;
right: 10px;
top: calc(50% - 10px);
}
<?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';
<?php
add_filter(
'jet-form-builder/forms/options-generators',
'add_custom_jfb_generator'
);
function add_custom_jfb_generator( array $generators ) {
$generators[] = new class extends \Jet_Form_Builder\Generators\Base {
@girafffee
girafffee / jet-fb-repeater-format-email.php
Last active June 26, 2023 10:16
Pretty formating repeater values in Send Email action content
<?php
/**
* Works in JetFormBuilder >= 2.1.0
*/
add_filter(
'jet-form-builder/send-email/template-repeater',
/**
* Verbose repeater items array
@girafffee
girafffee / jfb-add-paypal-webhooks.php
Last active September 16, 2022 13:35
User case: change user role on PayPal webhooks
<?php
/**
* Hands up! If you are using version 1.1.0 or higher. You won't need the code below. Just use new events
* @link https://user-images.githubusercontent.com/46720998/190651417-bba9c801-812c-4d8e-bbf4-d32075bc4fd7.png
*
*
*
* This gist is an extended version of this gist.
* @link https://gist.github.com/girafffee/040ff0ec2f148cd429d4a91cc7006c50#file-jfb-add-paypal-webhooks-php
@girafffee
girafffee / jfb-add-paypal-webhooks.php
Created April 14, 2022 07:52
Example of adding a PayPal listener to subscribe to the cancel event
<?php
function jfb_add_paypal_webhooks( array $webhooks ) {
require_once 'jfb-paypal-cancel-subscription-webhook.php';
$webhooks[] = new JFB_Paypal_Cancel_Subscription_Webhook();
return $webhooks;
}
@girafffee
girafffee / add-product.php
Created September 21, 2021 07:38
Add WooCommerce product with using Custom Hook
<?php
use Jet_Form_Builder\Actions\Action_Handler;
use Jet_Form_Builder\Exceptions\Action_Exception;
/**
* add-product - the name of your custom hook
*/
add_action( 'jet-form-builder/custom-action/add-product', function ( $request, Action_Handler $handler ) {
if ( ! function_exists( 'wc_get_product' ) ) {
return;
@girafffee
girafffee / wc-action-add-to-cart.php
Last active August 20, 2021 07:39
This is an example of working with a hook that is triggered when an item is added to the cart via the addon WooCommerce Cart & Checkout Action
<?php
/**
* This is an example of working with a hook
* that is triggered when an item is added to the cart via the addon
* @link https://jetformbuilder.com/addons/woocommerce-cart-checkout-action/
*
* Works with both JetFormBuilder and JetEngine Forms
*/
@girafffee
girafffee / jet-fb-custom-hook-api.php
Created June 24, 2021 13:56
How to set JetFormBuilder form statuses
<?php
use Jet_Form_Builder\Exceptions\Action_Exception;
add_action( 'jet-form-builder/custom-action/test_action', function ( $request, $handler ) {
if ( empty( $request['age'] ) ) {
/**
* You can use one of the default statuses
* 'success' => 'Form successfully submitted.',
* 'failed' => 'There was an error trying to submit form. Please try again later.',
@girafffee
girafffee / jet-engine-use-inserted-post-id.php
Last active January 31, 2022 17:27
Using data from the form, insert post id, notification settings
<?php
$on_insert_port = function ( $settings, $notification ) {
if ( 'post' !== $settings['post_type'] ) {
return;
}
/**
* To get/set the entered data from the form use $notification->data
*/