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 / code.html
Last active September 24, 2019 18:55
Create simple date difference using jQuery datepicker
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<link href="https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
@bappi-d-great
bappi-d-great / wpmudev-coursepress-completion-email.php
Last active September 6, 2019 06:07 — forked from wpmudev-sls/wpmudev-coursepress-completion-email.php
[ CoursePress 2 ] - Email Notifications on Completion. Sends an email notification to the Student upon Course Completion
<?php
/**
* Plugin Name: [ CoursePress 2 ] - Email Notifications on Completion
* Plugin URI: https://premium.wpmudev.org/
* Description: Sends an email notification to the Student upon Course Completion
* Author: Alessandro Kaounas @ WPMUDEV
* Author URI: https://premium.wpmudev.org/
* License: GPLv2 or later
*/
@bappi-d-great
bappi-d-great / How to use custom post type archive as front page.php
Last active July 30, 2019 22:49
How to use custom post type archive as front page
<?php
/*
* 1. Go to Settings > Permalinks and select any page as home page
* Then use the following code
*
* You can add those codes in your functions.php in the theme, if you think your theme won’t be changed.
* Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'.
* If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that,
* give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins,
* so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.
@bappi-d-great
bappi-d-great / code.php
Created August 17, 2017 18:01
Auto enroll to a course based on Membership - CoursePress2 and Membership2
<?php
add_action( 'ms_model_relationship_create_ms_relationship_before', 'ms_controller_member_assign_memberships_done_cb', 99, 4 );
function ms_controller_member_assign_memberships_done_cb( $membership_id, $user_id, $gateway_id, $move_from_id ) {
$course = array(
// 'membership_id' => 'course_id'
'1324' => 6656,
'9087' => 22345
);
@bappi-d-great
bappi-d-great / 1-instructions.txt
Last active April 9, 2019 05:39
Add custom field in M2 registration form (Basic) WPMU Membership2
### We are adding telephone number as custom field
1. Go to /wp-content/plugins/membership/app/view/templates/ and copy all 4 files.
2. Go to /wp-content/themes/YOUR_CURRENT_THEME/ and create a new folder called membership2, then paste all 4 files inside the new created membership2 folder
3. Open membership_registration_form.php and put the following: membership_registration_form.php
4. Now open the membership_account.php file and put the following: membership_account.php
5. Finally need to add some code: mu-plugin.php
## You can add those codes in your functions.php in the theme,
## if you think your theme won’t be changed. Otherwise mu-plugins is the best solution.
@bappi-d-great
bappi-d-great / How to write dynamic css in a php file in wordpress.php
Last active February 11, 2019 18:48
How to write dynamic css in a php file in wordpress
<!-- functions.php -->
<?php
add_action( 'wp_enqueue_scripts', 'theme_custom_style_script', 11 );
function theme_custom_style_script() {
wp_enqueue_style( 'dynamic-css', admin_url('admin-ajax.php').'?action=dynamic_css', '', VERSION);
}
add_action('wp_ajax_dynamic_css', 'dynamic_css');
add_action('wp_ajax_nopriv_dynamic_css', 'dynamic_css');
@bappi-d-great
bappi-d-great / code.php
Created September 21, 2016 20:40
WPMU Membership 2: Adding more column in member table
<?php
/**
* Example: User ID
*/
add_filter( 'ms_helper_listtable_member_get_columns', function( $columns ) {
$columns['user_id'] = 'User ID';
return $columns;
@bappi-d-great
bappi-d-great / code.php
Created September 21, 2016 20:42
WPMU Membership 2: Adding more column in billing table and sorting example
<?php
/**
* Example: Member first name and last name and sorting ASC and DESC
*/
add_filter( 'ms_helper_listtable_billing_get_columns', function( $columns, $currency ) {
$columns['first_name'] = 'First Name';
$columns['last_name'] = 'Last Name';
@bappi-d-great
bappi-d-great / code.php
Created September 24, 2016 18:52
WPMU Membership assign membership based on role on registration
<?php
add_action( 'user_register', 'assign_membership_on_register', 10, 1 );
function assign_membership_on_register( $user_id ) {
$membership = array(
// 'role' => 'membership ID'
'abc' => 123,
'xyz' => 456
);
<?php
add_filter(
'ms_model_membership_create_new_user_validation_errors',
'new_pw_validation_rule',
20, 2
);
function new_pw_validation_rule( $validation_errors, $obj )
{