Skip to content

Instantly share code, notes, and snippets.

View bappi-d-great's full-sized avatar

Bappi D great bappi-d-great

View GitHub Profile
@bappi-d-great
bappi-d-great / get_forms.php
Created June 25, 2018 18:49
get_forms.php
<?php
$forms = Forminator_API::get_forms(); // Method 1 to get all forms
$form_ids = array( 12, 34, 56, 78, 90 );
$forms = Forminator_API::get_forms( $form_ids ); // Method 2 to get specific forms
$forms = Forminator_API::get_forms(12, 34, 56, 78, 90 ); // Method 3 to get specific forms
@bappi-d-great
bappi-d-great / code.php
Created May 22, 2018 11:48
Allow Subsite admin to access new privacy menu by default
<?php
add_filter( 'map_meta_cap', function( $caps, $cap, $user_id, $args ) {
switch( $cap )
{
case 'export_others_personal_data':
case 'erase_others_personal_data':
case 'manage_privacy_options':
if( ( $key = array_search( 'manage_network', $caps ) ) !== false ) {
unset( $caps[$key] );
}
@bappi-d-great
bappi-d-great / code.php
Created May 8, 2018 19:44
WPMU DEV MarketPress: Support schema.org for product price
<?php
add_filter( 'mp_format_currency_symbol', function() {
return 'USD ';
} );
add_filter( 'mp_product/display_price', function( $snippet, $price, $id ) {
$product = new MP_Product( $id );
@bappi-d-great
bappi-d-great / code.php
Created April 11, 2018 09:09
WPMU Membership2: Set different thank you page based on membership
<?php
add_filter( 'ms_model_pages_redirect_to', function( $url, $type, $args ) {
$subscription_id = $args['ms_relationship_id'];
$subscription = MS_Factory::load( 'MS_Model_Relationship', $subscription_id );
$membership = $subscription->get_membership();
if( $membership->id == XX )
{
@bappi-d-great
bappi-d-great / code.php
Last active March 26, 2018 10:48
Forminator: Date field - drop down/input type - follow the date format to show the fields
<?php
add_filter( 'forminator_field_date_markup', function( $html, $field ) {
$id = $name = Forminator_Date::get_property( 'element_id', $field );
$type = Forminator_Date::get_property( 'field_type', $field );
$date_format = Forminator_Date::get_property( 'date_format', $field );
$min_year = $max_year = '';
$sep = false !== strpos( $date_format, '/' ) ? '/' : '-';
@bappi-d-great
bappi-d-great / code.php
Last active August 29, 2018 15:41
WPMU DEV Forminator Pro: Use a form as registration form (Beta)
<?php
if( ! class_exists( 'Forminatio_Registration_Addon' ) )
{
class Forminatio_Registration_Addon
{
// Registration Form ID
static $Form_ID = '4599';
static $map = array(
@bappi-d-great
bappi-d-great / code.php
Created February 5, 2018 17:37
PROGRAMMATICALLY UPDATE ADDITIONAL FIELD'S VALUE for an appointment WPMU DEV
<?php
function update_app_add_field_val( $app_id, $add_field, $add_val )
{
global $appointments, $wpdb;
$appmeta = appointments_get_table( 'appmeta' );
$meta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $appmeta WHERE app_appointment_id = %d and meta_key = %s ", $app_id, 'additional_fields' ));
$meta = maybe_unserialize( $meta[0]->meta_value );
$meta[$add_field] = $add_val;
@bappi-d-great
bappi-d-great / code.php
Created February 5, 2018 17:32
WPMU DEV Appointments+ enable enter key in the appointments login form
<?php
add_action( 'wp_head', function() {
?>
<script type="text/javascript">
jQuery(function($){
$('.app_username, .app_password').keypress(function(event) {
var keycode = event.keyCode || event.which;
if( keycode == 13 ) $('.appointments-login_link-submit').click();
});
@bappi-d-great
bappi-d-great / code.php
Created February 2, 2018 17:25
WPMU DEV marketpress - give a discount, for example 10%, to all products without updating all products price value
<?php
add_filter( 'mp_product/get_price', function( $price, $obj ) {
foreach( $price as $key => $val )
{
if( is_numeric( $price[ $key ] ) )
{
$price[ $key ] = $val * 0.9;
}
}
@bappi-d-great
bappi-d-great / code.js
Created January 22, 2018 08:03
Simple grunt script to make a plugin package
/*global require*/
/**
* When grunt command does not execute try these steps:
*
* - delete folder 'node_modules' and run command in console:
* $ npm install
*
* - Run test-command in console, to find syntax errors in script:
* $ grunt hello