Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / decode_html_entities.js
Created October 7, 2016 09:38 — forked from DylanCodeCabin/decode_html_entities.js
Decodes html entities back to normal html
function decodeHtmlEntities(str) {
console.log(str);
var special = {
"&lt;" : "<",
"&gt;" : ">",
"&quot;" : '"',
"&apos;" : "'",
"&#039;" : "'",
"&amp;" : "&",
"\\" : ""
@andrewlimaza
andrewlimaza / gist:0eff5977c9aa188bd001fdd9d0a00d85
Created October 20, 2016 13:45 — forked from r-a-y/gist:5578432
Disable BuddyPress' registration and use WP's instead. Paste this in /wp-content/plugins/bp-custom.php.
/**
* Disables BuddyPress' registration process and fallsback to WordPress' one.
*/
function my_disable_bp_registration() {
remove_action( 'bp_init', 'bp_core_wpsignup_redirect' );
remove_action( 'bp_screens', 'bp_core_screen_signup' );
}
add_action( 'bp_loaded', 'my_disable_bp_registration' );
@andrewlimaza
andrewlimaza / show_pmpro_address_fields_on_edit_profile.php
Last active April 18, 2017 07:12 — forked from strangerstudios/show_pmpro_address_fields_on_edit_profile.php
Use PMPro Register Helper to add PMPro Billing Address fields to the edit user page for admins or users.
/*
Use PMPro Register Helper to add PMPro Billing Address fields to the edit user page for admins.
*/
function show_pmpro_address_fields_on_edit_profile()
{
//require PMPro and PMPro Register Helper
if(!defined('PMPRO_VERSION') || !defined('PMPRORH_VERSION'))
return;
$address_fields = array(
<?php
/*
* Load iFlyChat Support or Chatroom for Members in Level 1 and 2 Only
* Update line 11 with your Membership Level IDs
*/
function my_pmpro_iflychat_check_access_filter($access) {
$access = true;
/** Get current user information **/
global $current_user;
wp_get_current_user();
@andrewlimaza
andrewlimaza / jquery-datepicker-wp-admin
Created July 24, 2017 10:59 — forked from slushman/jquery-datepicker-wp-admin
How to Add the jQuery UI Datepicker to the WordPress Admin
/**
* Adds the datepicker settings to the admin footer.
* Only loads on the plugin-name settings page
*/
function admin_footer() {
$screen = get_current_screen();
if ( $screen->id == 'settings_page_plugin-name' ) {
@andrewlimaza
andrewlimaza / init_session_var_test.php
Last active April 21, 2020 08:07 — forked from strangerstudios/init_session_var_test.php
Testing if $_SESSION variables work in WordPress/PHP. Test session
function init_session_var_test()
{
//must set /?sessiontest=SOMETHING to get this to run
if(empty($_REQUEST['sessiontest']))
return;
//start session
if (version_compare(phpversion(), '5.4.0', '>=')) {
if (session_status() == PHP_SESSION_NONE)
session_start();
@andrewlimaza
andrewlimaza / pmpromyCRED.php
Last active May 15, 2024 20:29 — forked from strangerstudios/pmpromyCRED.php
Award MyCRED Points for membership check outs and renewals.
<?php
/**
* Add MyCRED points to whenever a user checksout for a PMPro Membership Level.
* Allows different points per membership level.
* Allows different points amount for membership renewals.
* Add this code below to your PMPro Customizations Plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* MyCRED can be downloaded/configured here: https://wordpress.org/plugins/mycred/
* Any questions, please feel free to visit www.paidmembershipspro.com
*/
@andrewlimaza
andrewlimaza / gist:49f30f9d91970eaf2fd0d7dc4f095a40
Created August 1, 2017 08:37 — forked from vxnick/gist:380904
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
@andrewlimaza
andrewlimaza / pmpro-assign-username-at-checkout.php
Created August 29, 2017 07:14 — forked from greathmaster/pmpro-assign-username-at-checkout.php
Assigns a random 6 digit number for a username automatically. Two variations...the first will show the username field with number already filled, but editing is disabled. The second variations (uncomment the lines) will not show the username field at all, but will simply generate the numerical username and display it on the confirmation page.
/*
Assigns a random 6 digit number for a username automatically.
Two variations...
the first will show the username field with number already filled, but editing is disabled.
The second variations (uncomment the lines) will not show the username field at all, but will simply generate the numerical username and display it on the confirmation page.
*/
function my_pmpro_checkout_after_user_fields()
{
echo "<script>";
@andrewlimaza
andrewlimaza / my_pmpro_widget_display_callback.php
Last active September 4, 2017 08:20 — forked from strangerstudios/my_pmpro_widget_display_callback.php
Hide widgets by sidebar ID on members only content when the current user does not have access.
<?php
/*
Update line 8 with the array of sidebar IDs you want to filter.
Add this code to your active theme's functions.php or a custom plugin.
*/
function my_pmpro_widget_display_callback($instance, $widget, $args) {
$hide_sidebars_array = array('sidebar-1','sidebar-2');
global $post;
//check if current user has an active membership level and hide the sidebars.