Skip to content

Instantly share code, notes, and snippets.

View serwis4u's full-sized avatar

Marek Rusak serwis4u

View GitHub Profile
<?php
/*
Plugin Name: UTF8mb4-convert
Version: 1.0
*/
function update_db_to_utf8mb4() {
if ( ! isset( $_GET['update-utf8bm4'] ) ) {
return;
}
<?php
// Adding this to get the form and entry object from Gravity Forms so I can test the connector.
add_action('gform_after_submission', 'print_form_and_entry_object', 10, 2);
function print_form_and_entry_object($entry, $form) {
ob_start();
var_dump($entry);
var_dump($form);
$contents = ob_get_contents();
ob_end_clean();
@serwis4u
serwis4u / pmpro-core-views-report-reset.php
Created May 7, 2020 10:16 — forked from pbrocks/pmpro-core-views-report-reset.php
Use this recipe to reset your PMPro site's Logins and Views Report data.
<?php
/**
* Place this code in your Customizations plugin, not including the opening php tag on line 1.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
/**
* Create a menu to give us a place to perform the reset. I'm choosing a Dashboard menu purely for ease of access.
*/
add_action( 'admin_menu', 'core_reset_views_admin_page' );
function core_reset_views_admin_page() {
@serwis4u
serwis4u / functions.php
Created September 9, 2019 11:30 — forked from numediaweb/functions.php
Filter WordPress admin side navigation menues
function filter_admin_menues() {
// If administrator then do nothing
if (current_user_can('activate_plugins')) return;
// Remove main menus
$main_menus_to_stay = array(
// Dashboard
'index.php',
@serwis4u
serwis4u / wp-fix-meta-serialization.php
Created June 24, 2019 22:08 — forked from kythin/wp-fix-meta-serialization.php
Fix wordpress serialized variables in custom meta data when running a migration
<?php
/*
* Wordpress postmeta find&replace code
*
* This file should be run on your source database to echo out update statements to run on your migrated database.
* It is to address the issue of when doing a find/replace on an sql file during a wordpress migration, that breaks
* any content changed within wordpress serialized meta values, particularly if you have custom post types etc.
*
* Do your normal find/replace over the exported sql, import it into your new database, then run this code and copy the resulting
* update SQL into your new database to fix it.
@serwis4u
serwis4u / wp-rocket-affiliatewp-cookies-cache.php
Created March 26, 2019 21:24 — forked from glueckpress/wp-rocket-affiliatewp-cookies-cache.php
[WordPress][WP Rocket] Creates cached files based on dynamic cookies for AffiliateWP. (WP Rocket 2.7+ required.)
<?php
/**
* Plugin Name: WP Rocket | AffiliateWP Cookie Cache
* Description: Creates a specific cache for each affiliate ref ID.
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* Plugin URI: https://gist.github.com/glueckpress/d379c5534708f440942523fe205ec840
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
@serwis4u
serwis4u / pmpro-change-role-custom-roles.php
Created April 16, 2018 19:40 — forked from unwiredtech/pmpro-change-role-custom-roles.php
Change roles for new PMPro members to custom roles at checkout based on level. Add this code to your active theme's functions.php or a custom plugin.
<?php
/*
This code assumes you already have custom roles created
for bronzemember, silvermember, and goldmember.
Members signing up for membership level #1 get "Bronze Member" role.
Members signing up for membership level #2 get "Silver Member" role.
Members signing up for membership level #3 get "Gold Member" role.
Members cancelling are given the subscriber role.
Admin users are ignored.
*/
add_action( "pmpro_after_change_membership_level", "e20r_cancel_at_end_of_period", 10, 2 );
add_filter( "pmpro_email_body", "e20r_email_body_for_cancel_msg", 10, 2 );
/**
* Change cancellation to set expiration date for next payment instead of cancelling immediately.
* Assumes monthly membership levels.
* Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
*
* @param (int) $level_id -- The membership levelId we're changing
* @param (int) $user_id -- The member we're changing levels for.
/*
Keep members start dates at checkout, even if switching levels.
*/
function custom_pmpro_checkout_start_date($date, $user_id, $level)
{
global $wpdb;
// Comment this out if you want to use the users registration date (Warning: Registration date may not contain data...)
$sqlQuery = "SELECT UNIX_TIMESTAMP(startdate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . esc_sql($user_id) . "' ORDER BY id LIMIT 1";
@serwis4u
serwis4u / pmpro_preserve_startdate.php
Created April 16, 2018 19:34 — forked from eighty20results/pmpro_preserve_startdate.php
Preserve initial startdate for member regardless of how the membership level is updated.
<?php
/*
Plugin Name: PMPro Preserve Startdate
Plugin URI: https://eighty20results.com/paid-memberships-pro/do-it-for-me/
Description: Customization to preserve initial membership signup (startdate) value.
Version: 1.0
Author: Thomas Sjolshagen @ Stranger Studios <[email protected]>
Author URI: https://eighty20results.com/thomas-sjolshagen/
*/
/*