Skip to content

Instantly share code, notes, and snippets.

View JudeRosario's full-sized avatar

Jude Rosario JudeRosario

View GitHub Profile
@JudeRosario
JudeRosario / matt.php
Created December 12, 2020 14:55
Update Manage Stock - Grouped products
/**
* Performs check before saving/inserting products
*/
function grouped_product_check($post_id, $post_data) {
// If this is just a revision, don't do anything.
if (wp_is_post_revision($post_id))
return;
if ($post_data['post_type'] == 'product') {
if( $post_data['post_parent'] != 0 ) {
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (current_user_can('subscriber')) {
show_admin_bar(false);
}
}
@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 / BuddyPress Profile Update via AJAX.js
Last active February 3, 2020 08:10
BuddyPress update xProfile via AJAX
jQuery(document).ready( function() {
jQuery("#appointment-edit-form-submit").click( function() {
// THIS CAUSED THE ERRORS
app_email = jQuery(this).attr("app_email")
app_phone = jQuery(this).attr("app_phone")
jQuery.ajax({
type : "post",
dataType : "json",
url : localhost://wp-admin/admin-ajax.php?action=save_xprofile,
data : {action: "save_xprofile", app_email : app_email, app_phone: app_phone},
location /map-front-end/ {
if (!-e $request_filename){
rewrite ^/maptiles/(.*\.(png|gif))$ /drawtile.php?tile=$1 break;
}
}
@JudeRosario
JudeRosario / aca.js
Created January 13, 2020 14:32
Get themes ADA Compliant by supplying defaults
$.each($('a'), function() {
alt = this.href.replace(/\/$/, "")
$(this).attr('alt', alt.substring(alt.lastIndexOf('/') + 1).replace(/-/g, " "));
});
$.each($('img'), function() {
alt = this.href.replace(/\/$/, "")
$(this).attr('alt', alt.substring(alt.lastIndexOf('/') + 1).replace(/-/g, " "));
});
function emailPreviousMonthReportTo($To)
{
global $wpdb;
//Get Last Months Report
$arrResult = $wpdb->get_results("SELECT `id`,
`date`,
`first_name`,
`last_name`,
`email`,