Skip to content

Instantly share code, notes, and snippets.

View JudeRosario's full-sized avatar

Jude Rosario JudeRosario

View GitHub Profile
@JudeRosario
JudeRosario / memberpress-hooks.php
Created April 13, 2020 08:33 — 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);
@JudeRosario
JudeRosario / mpca-mange-sub-account-links.php
Created April 13, 2020 08:33 — forked from cartpauj/mpca-manage-sub-account-links.php
Get Manage Sub Account Links for Currently Logged In User - MemberPress Corporate Accounts
@JudeRosario
JudeRosario / auto-approve-memberpress-new-user-approve.php
Created April 13, 2020 08:33 — forked from cartpauj/auto-approve-memberpress-new-user-approve.php
Auto Approve Sub Accounts - and a list of Memberships by ID
<?php
// allow for verification to be required for free trial users.
function mepr_newuser_approve_override($user_id) {
$auto_approve = array(970688, 970684, 970687, 970686, 970685); //An array of product ID's to auto approve
if(!class_exists('MeprOptions')) { return; }
if(!isset($_POST['mepr_product_id']) && !isset($_POST['manage_sub_accounts_form'])) { return $user_id; } //Not a MemberPress signup?
$product_id = isset($_POST['mepr_product_id'])?$_POST['mepr_product_id']:false;
@JudeRosario
JudeRosario / memberpress-corporate-all-sub-accounts.php
Created April 13, 2020 08:29 — forked from cartpauj/memberpress-corporate-all-sub-accounts.php
Get all sub-accounts for a parent user in MemberPress Corporate Accounts
<?php
$user = MeprUtils::get_currentuserinfo();
$sub_user_ids = array();
if($user !== false) {
$transactions = $user->active_product_subscriptions('transactions');
if(!empty($transactions)) {
foreach($transactions as $txn) {
if(($sub = $txn->subscription()) !== false) {
@JudeRosario
JudeRosario / 1-instructions.txt
Created December 7, 2016 13:51 — forked from bappi-d-great/1-instructions.txt
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.
@JudeRosario
JudeRosario / wc-free-checkout-fields.php
Last active July 12, 2018 21:57 — forked from bekarice/wc-free-checkout-fields.php
Simplify WooCommerce checkout fields for free checkouts
<?php
function sv_free_checkout_fields() {
global $woocommerce ;
// Bail we're not at checkout, or if we're at checkout but payment is needed
if ( ! is_checkout() || ( is_checkout() && WC()->cart->needs_payment() ) ) {
return;
}
@JudeRosario
JudeRosario / 0_reuse_code.js
Last active August 29, 2015 14:28
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@JudeRosario
JudeRosario / Follow Up Email Snippet
Last active August 29, 2015 14:27 — forked from anonymous/Follow Up Email Snippet
Suzy - Follow Up Email Code Appt+
add_filter( 'app_message_headers', 'custom_headers' );
function custom_headers( $message_headers ){
$message_headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
return $message_headers;
}
function follow_up( $value ) {
global $wpdb, $appointments;
$a = $appointments;
#!/bin/bash
## Bash Script to clear cached memory on (Ubuntu/Debian) Linux
## Thanks to Philipp Klaus
if [ "$(whoami)" != "root" ]
then
echo "You have to run this script as Superuser!"
exit 1
fi