Skip to content

Instantly share code, notes, and snippets.

View Lonsdale201's full-sized avatar

Soczó Lonsdale201

View GitHub Profile
@Lonsdale201
Lonsdale201 / code
Created May 12, 2024 07:36
JetEngine - Calculated callback - Age calc
// This code uses the date meta to calculate how many years old. The calculation is done using
// the year from the given meta and the current date. The returned number simply returns the years.
// Can also be used with user listings.
// Ideally, the user should be able to specify when they were born, so that you can use the
// calculation to return how old they are at the moment.
// copy this code in the child theme functions.php or a specific code plugin like FluentSnippets
// For the code to work, you need to install the Calculated Callback Add-on addons
// Plugin: https://github.com/MjHead/jet-engine-calculated-callback
@Lonsdale201
Lonsdale201 / code
Created May 9, 2024 08:24
JetEngine - Calculated callback - Calculate Hours and Minutes
// This code can convert the number values to Hours, and minutes.
// Example, your meta store: "125" this calc can output to: 2h5m so 2 hours, and 5 minutes
// copy this code in the child theme functions.php or a specific code plugin like FluentSnippets
// For the code to work, you need to install the Calculated Callback Add-on addons
// Plugin: https://github.com/MjHead/jet-engine-calculated-callback
// Plugin desc: https://crocoblock.com/knowledge-base/jetengine/calculated-callback-add-on/#custom-callback
// when you pasted the code, open the Elementor editor, and place the Dynamic Field widget, enable the Filter Field output
// in the dropdown, select the Calculated field Callback
@Lonsdale201
Lonsdale201 / code
Last active May 9, 2024 08:25
JetEngine - Calculated callback Lowest highset between calc
// copy this code in the child theme functions.php or a specific code plugin like FluentSnippets
// This code Based on the meta values you enter (you should enter at least 3), it will find the smallest and largest values and output them.
// For the code to work, you need to install the Calculated Callback Add-on addons
// Plugin: https://github.com/MjHead/jet-engine-calculated-callback
// Plugin desc: https://crocoblock.com/knowledge-base/jetengine/calculated-callback-add-on/#custom-callback
// when you pasted the code, open the Elementor editor, and place the Dynamic Field widget, enable the Filter Field output
// in the dropdown, select the Calculated field Callback
@Lonsdale201
Lonsdale201 / gist:1828802569ece230a15463b51bf62aa4
Created March 17, 2024 13:48
JetEngine - Dynamic Visibility - Tutor LMS - User enrolled current course
// place the code in the child theme functions.php or a custom code snippets plugin.
// This snippet will register a new dynamic visibility condition
// Work with only TUTOR LMS
// plugin : https://wordpress.org/plugins/tutor/
add_action( 'jet-engine/modules/dynamic-visibility/conditions/register', function( $conditions_manager ) {
class Tutor_LMS_User_Enrolled_Course_Visibility extends \Jet_Engine\Modules\Dynamic_Visibility\Conditions\Base {
public function get_id() {
@Lonsdale201
Lonsdale201 / gist:89668ae90c00cd40bd3005b9fed25eff
Last active March 14, 2024 15:59
JetEngine - Calculated callback Datetime difference
// copy this code in the child theme functions.php or a specific code plugin like FluentSnippets
// For the code to work, you need to install the Calculated Callback Add-on addons
// Plugin: https://github.com/MjHead/jet-engine-calculated-callback
// Plugin desc: https://crocoblock.com/knowledge-base/jetengine/calculated-callback-add-on/#custom-callback
// when you pasted the code, open the Elementor editor, and place the Dynamic Field widget, enable the Filter Field output
// Note that this calculation works correctly only for : DateTime meta
// The order matters. The first meta argument will be compared with the second.
// in the dropdown, select the Calculated field Callback
@Lonsdale201
Lonsdale201 / gist:8570877cfc136192c727bae61b64efee
Last active April 29, 2024 13:38
JetEngine - Calculated callback Date difference
// copy this code in the child theme functions.php or a specific code plugin like FluentSnippets
// For the code to work, you need to install the Calculated Callback Add-on addons
// Plugin: https://github.com/MjHead/jet-engine-calculated-callback
// Plugin desc: https://crocoblock.com/knowledge-base/jetengine/calculated-callback-add-on/#custom-callback
// when you pasted the code, open the Elementor editor, and place the Dynamic Field widget, enable the Filter Field output
// Note that this calculation works correctly only for : Date meta
// The order matters. The first meta argument will be compared with the second.
// in the dropdown, select the Calculated field Callback
@Lonsdale201
Lonsdale201 / gist:24ede06b773d1e9a53c25c5354bf9442
Created February 13, 2024 21:34
Learndash - programatically course enroll with wp registration
// copy this code in the child theme functions.php or a specific code plugin like FluentSnippets
add_action( 'user_register', 'auto_enroll_user_to_course', 10, 1 );
function auto_enroll_user_to_course( $user_id ) {
if ( ! is_wp_error( $user_id ) ) {
$course_ids = array( 131 ); // Course ID, or ID's user separate comme if you want to add multiple id.
if ( !is_array( $course_ids ) ) {
$course_ids = array( $course_ids );
}
@Lonsdale201
Lonsdale201 / gist:35b668c05fa4cb0a340481eb1ab7bcee
Last active January 18, 2024 21:16
JetEngine - Dynamic Visibility - Fluent CRM Lists
// place the code in the child theme functions.php or a custom code snippets plugin like Fluent Snippts etc..
// This conditions required the FluentCRM plugin to be installed and activated on your site. This Conditions only work with
// LOGGED IN USERS + user need to Contant in your CRM
// https://fluentcrm.com/
// https://wordpress.org/plugins/fluent-crm/
// Only Elementor
// HOW TO
// Go to your , widget container etc, open the Dynamic Visibility modul, and scroll down and select the Fluent CRM Lists option
// In the next select field, choose one or more Lists (Internal operator OR)
// don't see any listings? That's because you haven't created them yet.
@Lonsdale201
Lonsdale201 / jetformbuilder
Last active May 9, 2024 08:26
JetFormBuilder - Select field (multiple) limit based on user role or guest
// Reference by default https://gist.github.com/Crocoblock/25125c7db9b19c60b1043061015556d0
// In the jetformbuilder Select field - use the Advanced section - Class field name, and add: select-limit
// Dont forget to enable the multiple option
// place the code in the child theme functions.php or a custom code snippets plugin.
// You can define if the user not logged in how many select item can check. This is the : 'guest' => 1,
// HOW TO
// In the $limits = [ add your role name like 'mycustomrole" => 4, where the "mycustomrole" is your role cap name, and the "4" is the limit
// Dont forget to target your select field, in the form gutenberg editor like the image: https://prnt.sc/Q4fqdpj3vgTH
@Lonsdale201
Lonsdale201 / jetformbuilder
Last active January 3, 2024 14:03
JetFormBuilder - Checkbox field limit based on user role or guest
// Reference by default https://gist.github.com/Crocoblock/d8bcacb6c851ae670bc0514f2f9173d6
// In the jetformbuilder checkbox field - use the Advanced section - Class field name, and add: check-limit
// place the code in the child theme functions.php or a custom code snippets plugin.
// You can define if the user not logged in how many checkbox can check. This is the : 'guest' => 1,
// HOW TO
// In the $limits = [ add your role name like 'mycustomrole" => 4, where the "mycustomrole" is your role cap name, and the "4" is the limit
// Dont forget to target your checkbox field, in the form gutenberg editor like the image: https://prnt.sc/FjqDLNL_q78m
// CSS Class name: check-limit