Skip to content

Instantly share code, notes, and snippets.

View Joel-James's full-sized avatar
🤸‍♂️
Working + Vacation

Joel James Joel-James

🤸‍♂️
Working + Vacation
View GitHub Profile
@bappi-d-great
bappi-d-great / code.php
Created February 6, 2017 17:11
WPMU Membership integration in Pro Site: Assign a membership to site admins when a Pro Site level is upgraded, downgraded or removed.
<?php
add_action( 'psts_withdraw', 'psts_withdraw_cb', 10, 2 );
add_action( 'psts_upgrade', 'psts_upgrade_cb', 10, 3 );
add_action( 'psts_downgrade', 'psts_downgrade_cb', 10, 3 );
function psts_withdraw_cb( $blog_id, $new_expire )
{
assign_membership_to_admins( $blog_id );
}
<?php
// Running validation
$this->validate($request, [
'user_id' => 'bail|required|integer|unique:users,user_id'
]);
@bappi-d-great
bappi-d-great / code.php
Created August 11, 2015 10:41
Remove role and assign subscriber role to the user or membership cancel
<?php
add_action( 'ms_model_event', 'my_event_handler', 10, 2 );
/**
* Handles an event and process the correct communication if required.
*
* @param MS_Model_Event $event The event that is processed.
* @param mixed $data The data passed to the event handler.
*/
@bappi-d-great
bappi-d-great / code.php
Created July 28, 2015 21:51
Assign role based on WPMU membership
<?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 ) {
$user = new WP_User( $user_id );
switch( $membership_id ){
case 1343:
$user->set_role( 'editor' );
break;
@discordier
discordier / gist:ed4b9cba14652e7212f5
Created December 4, 2014 06:23
options for phpStorm @noinspection annotation
javascript
ES6ValidationInspection
JSAccessibilityCheckInspection
JSBitwiseOperatorUsageInspection
JSCheckFunctionSignaturesInspection
JSClosureCompilerSyntaxInspection
JSCommentMatchesSignatureInspection
JSComparisonWithNaNInspection
JSConsecutiveCommasInArrayLiteralInspection
@uglyrobot
uglyrobot / package-plugin
Last active September 14, 2017 07:28
A shell script for easy tagging and clean zip packaging of a WordPress Plugin/Theme in git.
#!/bin/bash
if [[ $# -eq 0 ]] ; then
echo "Please enter a version number:"
read VERSION
else
VERSION=$1
fi
if [[ -z "$VERSION" ]] ; then
echo "Sorry, I need a version number!"