Skip to content

Instantly share code, notes, and snippets.

View nextab's full-sized avatar

nexTab - Oliver Gehrmann nextab

View GitHub Profile
add_filter("jet-form-builder/render/hidden-field", function( $args ) {
if ( function_exists( 'jet_engine' ) ) {
$args[ 'field_value' ] = jet_engine()->listings->macros->do_macros( $args[ 'field_value' ] );
}
return $args;
});
// You can add this filter to functions.php:
add_filter('jet-search/ajax-search/custom-post-data', function( $custom_data, $data, $post ) {
$custom_data['post_id'] = $post->ID ?? 0;
return $custom_data;
}, 0, 3 );
// And then use {{{data.post_id}}} in the template.
/**
* Remove bloated inline core color styles.
*
* @param \WP_Theme_JSON_Data $theme_json Class to access and update the underlying data.
*
* @return \WP_Theme_JSON_Data
*/
add_filter(
'wp_theme_json_data_default',
function( $theme_json ) {
#region Update CCT helper function
/**
*
* Helper function to update the row(s) of a CCT table
*
* @param array $values column names and value pairings
* @param array $where specify what to update
* @param $table_name slug of the CCT; global WPDB prefix and 'jet_cct_' will be appended; defaults to 'user_information'
*
* @return bool returns true on success; false on fail
#region Registration part 1 - Custom Action for JetFormBuilder
add_action( 'jet-form-builder/custom-action/user-activation-code', function( $request, $action_handler ) {
$cct_id = ! empty( $request['inserted_cct_user_information'] ) ? $request['inserted_cct_user_information'] : false;
$user_email = ! empty( $request['e_mail'] ) ? $request['e_mail'] : false;
if($cct_id <= 0) {
error_log("CCT for user information could not be created; CCT ID: {$cct_id};");
if($user_email !== false) {
error_log("Submitted e-mail for user: {$user_email};");
}
return;
#region Check Activation Code
/**
*
* @param $value mixed
* @param $context \Jet_Form_Builder\Request\Parser_Context
*
* @return bool
*/
function jet_fb_v_activation_code_check( $value, $context ): bool {
$user = wp_get_current_user();
#region CCT Lookup - Get (single) field in CCT from JetEngine table
/**
*
* @param string $find_column column name to find
* @param string $needle - value that needs to be checked against
* @param string $lookup_column - column name to check $needle against
* @param string $table - slug of the CCT; global WPDB prefix and 'jet_cct_' will be appended; defaults to 'user_information'
*
* @return string|null returns the value of the $find_column if the $lookup_column matches the $needle; null if no match is found
*
#region Enqueue Gutenberg Scripts
add_theme_support( 'custom-spacing' );
add_theme_support( 'border' );
add_theme_support( 'appearance-tools' );
#endregion Enqueue Gutenberg Scripts
#region Check if e-mail has already signed up for this event
function jet_fb_v_unique_mail_for_event( $value, $context ): bool {
$fields = $context->get_request();
$mails = get_mails_for_event($fields['event_id']);
// If mails list is empty or the email is not in the list, it's unique
return !in_array($value, $mails, true);
}
#endregion Check if e-mail has already signed up for this event
#region Get all e-mails for current event
@nextab
nextab / Zuweisung von CCT - Custom Content Types zu einem Benutzer nachdem eine bestimmte Seite aufgerufen wird (per Shortcode).php
Created September 20, 2023 06:46
/* Wenn Submissions über ein JetForm per Gast-Modus zugelassen werden, muss man dem Benutzer später noch die Form Submission zuweisen, damit er diese auch bearbeiten kann; um bei späterer Registrierung die Zuweisung zuzunehmen empfiehlt sich eine entsprechende Logik. Der Shortcode [sort_event_registrations] muss hier noch auf der zugehörigen My …
/* Wenn Submissions über ein JetForm per Gast-Modus zugelassen werden, muss man dem Benutzer später noch die Form Submission zuweisen, damit er diese auch bearbeiten kann; um bei späterer Registrierung die Zuweisung zuzunehmen empfiehlt sich eine entsprechende Logik.
Der Shortcode [sort_event_registrations] muss hier noch auf der zugehörigen My Account Page eingebunden werden. */
#region Assign signups to newly registered users
// Add the action to hook into the user_register event
function nxt_update_event_signups($user_id) {
// Get the newly created user's email
$new_user_email = get_user_data();
if($new_user_email === false) return;