Skip to content

Instantly share code, notes, and snippets.

View MjHead's full-sized avatar

Andrew Shevchenko MjHead

  • Crocoblock
  • Ukraine
View GitHub Profile
<?php
add_action( 'edit_user_profile', 'my_user_likes' );
add_action( 'show_user_profile', 'my_user_likes' );
function my_user_likes( $user ) {
// user-meta-store you need to replace with your actual Data Store slug
$liked = get_user_meta( $user->ID, 'je_data_store_user-meta-store', true );
echo '<h2>User Likes</h2>';
@MjHead
MjHead / cct-admin-column-callback.php
Created October 6, 2020 13:31
Add custom callback for the CCT admin column
<?php
/*
form_submissions - replace this with your actual CCT slug
cct_single_post_id - replace this with your actual field name
*/
add_filter( 'jet-engine/custom-content-types/admin-columns', function( $columns, $factory ) {
if ( 'form_submissions' === $factory->get_arg( 'slug' ) && isset( $columns['cct_single_post_id'] ) ) {
$columns['cct_single_post_id']['_cb'] = 'my_get_edit_post_link';
}
@MjHead
MjHead / get-cct-from-code.php
Last active October 5, 2020 07:50
Get Custom Content Type items from the code
<?php
/**
This function should be called on the 'init' hook with priority 11 or later,
if not custom content type instances will not be registered yet
Available operators:
=
!=
<?php
add_shortcode( 'post_terms', function( $atts = array() ) {
$atts = shortcode_atts( array(
'tax' => '',
'tax_2' => '',
'tax_3' => '',
), $atts, 'post_terms' );
@MjHead
MjHead / jet-engine-metabox-from-code.php
Created February 26, 2020 08:31
Register custom meta box for JetEngine from code
<?php
add_action( 'jet-engine/meta-boxes/register-instances', 'my_register_meta_box' );
function my_register_meta_box( $meta_boxes_manager ) {
// Replace my_post_type_slug with your actual post type slug
$post_type = 'my_post_type_slug';
$object_name = $post_type . '_group';
@MjHead
MjHead / jet-engine-metabox-from-code.php
Created February 26, 2020 08:31
Register custom meta box for JetEngine from code
<?php
add_action( 'jet-engine/meta-boxes/register-instances', 'my_register_meta_box' );
function my_register_meta_box( $meta_boxes_manager ) {
// Replace my_post_type_slug with your actual post type slug
$post_type = 'my_post_type_slug';
$object_name = $post_type . '_group';
@MjHead
MjHead / attachment-link-callback.php
Created February 20, 2020 14:01
Get attachment link by attachment ID callback for JetEngine
<?php
add_filter( 'jet-engine/listings/macros-list', 'jet_register_custom_macros' );
/**
* Add new macros to default macros list
*
* %business_users% - macros name
*
*/
<?php
add_action( 'import_post_meta', function( $post_id, $key, $value ) {
$slashit = array( '_form_data', '_notifications_data' );
if ( in_array( $key, $slashit ) && '[]' !== $value ) {
delete_post_meta( $post_id, $key );
update_post_meta( $post_id, $key, $value );
}
<?php
add_action( 'jet-engine/forms/booking/notification/insert_post', function( $notification, $manager ) {
if ( ! empty( $manager->data['_date_field'] ) ) {
$manager->data['_date_field'] = strtotime( $manager->data['_date_field'] );
}
}, 0, 2 );