Skip to content

Instantly share code, notes, and snippets.

@ihslimn
ihslimn / code.php
Last active June 22, 2024 21:38
JetFormBuilder Log out inactivated users
<?php
add_action( 'jet-form-builder/custom-action/log-out-inactivated', function() {
$user_id = get_current_user_id();
if ( ! $user_id ) {
return;
}
@ihslimn
ihslimn / code.php
Last active June 22, 2024 21:38
JetFormBuilder Advanced validation - query results
<?php
function jet_fb_v_query_has_results_447( $value ) {
$query_id = ( int ) str_replace( 'jet_fb_v_query_has_results_', '', __FUNCTION__ );
return check_query_has_results( $value, $query_id );
}
@ihslimn
ihslimn / code.php
Last active November 13, 2023 15:29
JetFormBuilder Get Order ID on Woocommerce Thank You page
<?php
add_filter( 'jet-form-builder/editor/hidden-field/config', function( $config ) {
$config['sources'][] = array(
'value' => 'cc_woocommerce_order_id',
'label' => 'Woocommerce Order ID (Thank You page)',
);
return $config;
@ihslimn
ihslimn / convert.md
Last active February 12, 2024 12:52
ACF save date as timestamp / convert saved dates to timestamp

Store ACF date field as timestamp

Automatically convert ACF date / datetime fields to timestamp on post save.
Add the following code and change field keys to correspond to the date / datetime field keys from your website

add_filter('acf/update_value/type=date_time_picker', 'my_update_value_date_time_picker', 10, 3);
add_filter('acf/update_value/type=date_picker', 'my_update_value_date_time_picker', 10, 3);

function my_update_value_date_time_picker( $value, $post_id, $field ) {
@ihslimn
ihslimn / code.js
Last active May 4, 2024 00:29
JetFormBuilder Reset form / current step
(
function( $ ) {
$( document ).ready( function() {
$( '[class*="reset-form-"]' ).click( resetForm );
$( '[class*="reset-step-"]' ).click( resetStep );
} );
function searchIds( classList, classBase ) {
@ihslimn
ihslimn / code.php
Last active June 22, 2024 21:44
JetFormBuilder Do JetEngine macros in hidden fields that are not rendered
<?php
add_action( 'jet-form-builder/form-handler/before-send', function( $form_handler ) {
if ( ! function_exists( 'jet_engine' ) ) {
return;
}
$form_id = $form_handler->form_id;
@ihslimn
ihslimn / code.html
Created September 27, 2023 10:59
JetPopup Disable closing popup on Elementor form submit
<script>
window.addEventListener( 'load', function( event ) {
let $ = jQuery;
$( window ).on( 'jet-popup/show-event/after-show', function ( event, params ) {
if ( ! params.data?.popupId ) {
return;
@ihslimn
ihslimn / code.php
Last active June 22, 2024 21:57
JetEngine Relation show parent/child ID
<?php
//shows parent ID in relation table when editing child
//replace 42 with relation ID
//replace 'parent_object' with 'child_object' if you need to show child ID in parent relation table
add_action( 'jet-engine/relations/init/42', function( $relation ) {
$relation->add_table_column( 'parent_object', 'parent_id', 'ID', function( $post_id ) {
@ihslimn
ihslimn / jfb-auto-scroll.html
Created July 25, 2023 14:25
JetFormBuilder Custom auto scroll
<script>
jQuery( document ).ready( function( $ ) {
let inited = false;
$( window ).on( 'jet-form-builder/init', function() {
if ( inited ) {
return;
@ihslimn
ihslimn / jet-engine-post-count-order.php
Created July 21, 2023 07:48
JetEngine Users Query order by CPT post count
<?php
class JetEngine_Users_Query_Post_Count_Order {
public function __construct() {
add_filter( 'jet-engine/query-builder/query/before-get-items', array( $this, 'modify_query' ), 0, 2 );
}
public function modify_query( $query, $cached ) {