Skip to content

Instantly share code, notes, and snippets.

View JudeRosario's full-sized avatar

Jude Rosario JudeRosario

View GitHub Profile
@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},
@JudeRosario
JudeRosario / Get Data from Cookie.php
Last active August 29, 2015 14:14
Appointments+ Code Snippets
@JudeRosario
JudeRosario / AJAX Handler.php
Last active March 15, 2016 00:02
A+ and BuddyPress xProfile Integration
add_action('wp_ajax_save_xprofile', 'save_appointment_settings_xprofile');
// Handles AJAX calls to the backend. Submit form with save_xprofile as action
function save_appointment_settings_xprofile(){
$profileuser = wp_get_current_user();
if ( isset( $_POST['app_email'] ) )
update_user_meta( $profileuser->ID, 'app_email', $_POST['app_email'] );
if ( isset( $_POST['app_phone'] ) )
update_user_meta( $profileuser->ID, 'app_phone', $_POST['app_phone'] );
// Get other variables like location from $_POST from here, if extending
@JudeRosario
JudeRosario / Membership Custom SQL.sql
Last active August 29, 2015 14:14
Membership SQL Queries
# Get Membership Activity during a specified period
SELECT * FROM wp_m_membership_news
WHERE newsdate
BETWEEN '2014-12-30 00:00:01' # Put start date here
AND '2014-12-31 23:59:59' # Put end date here
# Members who successfully paid during a specified period
SELECT wp_users.ID, user_email, user_login, display_name, paymentmade, paymentexpires
@JudeRosario
JudeRosario / Membership + MailChimp.php
Last active August 29, 2015 14:14
Integrate Membership with MailChimp API
add_action('register_user','mailchimp_add_to_list')
function mailchimp_add_to_list ($user_id)
{
// Get Full Name and Email from BuddyPress
$name = bp_core_get_user_displayname( $user_id );
$email = bp_core_get_user_email($user_id);
@JudeRosario
JudeRosario / CF + WPAM.php
Created January 29, 2015 10:20
Integrate WP - Affiliates Manager + Contact Form 7 + Membership
private function add_hooks () {
// Modify here if changing contact form
add_action('wpcf7_mail_sent',array($this,'integrate_affiliate_code',));
}
private function integrate_affiliate_code () {
// Use a jsonHandler to manually add 5 Pounds to the affiliate
$jsonHandler = new WPAM_Util_JsonHandler;
// Modify here if you want to increase payouts or switch affiliate plugins
$jsonHandler->addTransaction($affiliate, 'credit',5, "Consultation Referral");
@JudeRosario
JudeRosario / Add the 4th Option(App+).php
Last active August 29, 2015 14:14
Add 4th Color to Appointments Table
// Add the 4th Option to the array
function get_classes() {
return apply_filters( 'app_box_class_names',
array(
'free' => __('Free', 'appointments'),
'busy' => __('Busy', 'appointments'),
'notpossible' => __('Not possible', 'appointments'),
// Add the option and description here
'free_but_collision' => __(‘Free, but Collision', 'appointments')
)
@JudeRosario
JudeRosario / Membership Refire Pings.php
Created February 2, 2015 09:04
Membership Ping SQL
// Function to get a list of users based on date joined / subscription type / level etc and refire pings
function refire_pings()
{
global $wpdb;
// The query string ( see below for more examples )
$query = "SELECT `ID` , `sub_id` , `level_id`, `user_email` , `user_login` , `display_name`
FROM `wp_m_membership_relationships`
INNER JOIN `wp_users` ON `wp_m_membership_relationships.user_id` = `wp_users.ID`
WHERE `startdate`
@JudeRosario
JudeRosario / Backend Check and Deduct.php
Last active November 23, 2015 00:51
myCred App+ Integration
// Once the appointment is confirmed, then process the myCreds.
add_filter('app_post_confirmation_status', 'confirm_manual_payments',10,5);
function confirm_manual_payments($status, $price, $service, $worker, $user_id) {
if("pending" === $status || "confirmed" === $status) :
global $wp, $current_user;
$mycred = mycred();
$current_user = wp_get_current_user();
$balance = round($mycred->get_users_balance( $current_user->ID ));
if ( $balance > 0 ) {
@JudeRosario
JudeRosario / Email Admin.php
Created February 3, 2015 18:13
Membership notify me on expiry
add_action( 'membership_expire_subscription', 'notify_expiry', 10, 2 );
function notify_expiry( $sub_id, $user_id ) {
$user = get_userdata($user_id);
// You can also filter only specific subscriptions here
$sub = Membership_Plugin::factory()->get_subscription( $sub_id );
// Put your email here
$to = 'put_your_email@here.com' ;
$subject = "Membership Expiry" ;
// Format email content if needed
$message = sprintf(__( '<strong>%s</strong> has left subscription <strong>%s</strong>','membership' ), $user->display_name, $sub->sub_name() );