Skip to content

Instantly share code, notes, and snippets.

View alokstha1's full-sized avatar

Alok Shrestha alokstha1

View GitHub Profile
@alokstha1
alokstha1 / mysql_cheat_sheet.md
Created November 1, 2023 01:07 — forked from bradtraversy/mysql_cheat_sheet.md
MySQL Cheat Sheet

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@alokstha1
alokstha1 / memberpress-hooks.php
Created May 28, 2020 13:41 — forked from cartpauj/memberpress-hooks.php
Various Subscription and Transaction status hooks for MemberPress with some helpful comments
<?php
//Capture a new member signup. Only ever triggers once for each new member.
//Does not trigger for exising members who have subscribed to a Membership before.
//
//The user may not be logged in when this is called
//as it is triggered when a user is added over the REST API,
//and also when a user is added from the dashboard (MemberPress -> Members -> Add New)
function mepr_capture_new_member_signup_completed($event) {
$user = $event->get_data();
$txn_data = json_decode($event->args);
@alokstha1
alokstha1 / mepr-active-memberships.php
Created August 9, 2019 04:13 — forked from cartpauj/mepr-active-memberships.php
Get a list of the current user's active MemberPress Subscriptions
<?php
if(class_exists('MeprUtils')) {
$user = MeprUtils::get_currentuserinfo();
if($user !== false && isset($user->ID)) {
//Returns an array of Membership ID's that the current user is active on
//Can also use 'products' or 'transactions' as the argument type
$active_prodcuts = $user->active_product_subscriptions('ids');
if(!empty($active_prodcuts)) {