Skip to content

Instantly share code, notes, and snippets.

View ioniacob's full-sized avatar
🐌
Exploring the code is like life itself.

Ion Iacob ioniacob

🐌
Exploring the code is like life itself.
View GitHub Profile
@paulcollett
paulcollett / functions.php
Last active April 10, 2025 14:16
Remove Yoast HTML Comments “This site is optimized with the Yoast WordPress SEO plugin”
// For Yoast SEO Plugin Version: 14.1+ add to your Wordpress Theme's functions.php...
// Remove All Yoast HTML Comments
// https://gist.github.com/paulcollett/4c81c4f6eb85334ba076
// Credit @devendrabhandari (https://gist.github.com/paulcollett/4c81c4f6eb85334ba076#gistcomment-3303423)
add_filter( 'wpseo_debug_markers', '__return_false' );
// For Yoast SEO Plugin Version: < 14.1 add to your Wordpress Theme's functions.php...
@amdrew
amdrew / gist:7f22b058a5defb240c48
Last active March 15, 2016 14:41
OptimizeMember + AffiliateWP. Allow affiliates to login/register and still be redirected to the affiliate area
function affwp_custom_op_login_redirect( $return, $vars ) {
$user_id = $vars['user_id'];
if ( function_exists( 'affwp_is_affiliate' ) && affwp_is_affiliate( $user_id ) ) {
$return = false;
}
return $return;
}
@amdrew
amdrew / gist:a8be1db4d11774418714
Last active August 29, 2015 14:18
OptimizePress + AffiliateWP. Shows how to load a different shortcode for different pages
function affwp_opi_add_tracking_shortcode() {
// this can be the page ID, page slug, or page title. Page title is shown below
if ( is_page( 'Your Success Page' ) ) {
echo do_shortcode( '[affiliate_conversion_script description="Your Description" amount="100"]' );
}
// another "thanks" page using a page ID
if ( is_page( 50 ) ) {
echo do_shortcode( '[affiliate_conversion_script description="A different description" amount="200"]' );
@gabrielmerovingi
gabrielmerovingi / mycred-hook-wp-courseware
Last active January 30, 2016 15:25
Custom myCRED Hook for WP Courseware. Points can be awarded or deducted for users completing units, modules and courses. Requires myCRED 1.6 or higher.
/**
* WP Courseware Hook
* @version 1.0.2
*/
add_filter( 'mycred_setup_hooks', 'mycred_register_courseware_hook' );
function mycred_register_courseware_hook( $installed ) {
$installed['courseware'] = array(
'title' => 'WP Courseware',
'description' => 'Award or deduct %plural% for users completing WP Courseware courses, modules or units.',
'callback' => array( 'myCRED_Hook_CourseWare' )
@ultimatemember
ultimatemember / gist:8743ef32801f7bf08c82
Created March 19, 2015 18:24
All members to automatically be WP contributors when they sign up via UM
add_action('um_after_user_is_approved', 'wp_role_contributor_after_um', 99 );
function wp_role_contributor_after_um( $user_id ) {
$wp_user_object = new WP_User( $user_id );
$wp_user_object->set_role( 'contributor' );
}
@ultimatemember
ultimatemember / gist:d98861b4c14a1540291b
Last active June 23, 2019 15:36
Conditionally sync UM user role based on WP role (Gravity forms)
/* This code will sync the UM role based on WP role using gravity registration */
add_action("gform_user_registered", "um_gravity_user_role_sync", 200, 4);
function um_gravity_user_role_sync($user_id, $config, $entry, $user_pass) {
$user = new WP_User( $user_id );
$wp_role = $user->roles[0];
// if WP role is subscriber, set UM role to member
if ( $wp_role == 'subscriber' ) {
@spivurno
spivurno / gp-auto-login-redirect-to-new-site.php
Created February 25, 2015 14:56
Gravity Perks // GP Auto Login // Redirect to New Site on Auto Login
/**
* Gravity Perks // GP Auto Login // Redirect to New Site on Auto Login
*/
add_filter( 'gpal_auto_login_on_redirect_redirect_url', function( $url, $user_id ) {
require_once( GFUser::get_base_path() . '/data.php' );
$entry_id = get_user_meta( $user_id, 'entry_id', true );
$site_id = GFUserData::get_site_by_entry_id( $entry_id );
@ultimatemember
ultimatemember / gist:1d81b59cd8b21f67b36c
Last active January 22, 2020 19:03
Add a hidden field to registration forms
add_action('um_after_register_fields', 'add_a_hidden_field_to_register');
function add_a_hidden_field_to_register( $args ){
echo '<input type="hidden" name="field_id" id="field_id" value="HERE_GOES_THE_VALUE" />';
}
@amdrew
amdrew / dashboard-tab-urls.php
Created January 14, 2015 03:28
AffiliateWP - Show the affiliate's username instead of affiliate ID in the affiliate dashboard
<?php
$affiliate = affwp_get_affiliate( affwp_get_affiliate_id() );
$user_info = get_userdata( $affiliate->user_id );
$affiliate_user_name = $user_info->user_login;
?>
<div id="affwp-affiliate-dashboard-url-generator" class="affwp-tab-content">
<h4><?php _e( 'Referral URL Generator', 'affiliate-wp' ); ?></h4>
var OAuth = require('oauth')
// `npm install oauth` to satisfy
// website: https://github.com/ciaranj/node-oauth
var KEY = "<INSERT KEY HERE>"
var SECRET = "<INSERT SECRET HERE>"
var oauth = new OAuth.OAuth(
'http://api.thenounproject.com',
'http://api.thenounproject.com',