Skip to content

Instantly share code, notes, and snippets.

View alexmangini's full-sized avatar

Alex Mangini alexmangini

View GitHub Profile
<?php
/**
* Debugging WordPress things.
*
* All of this belongs in your wp-config.php file.
*
* This will make sure that the code you release is, at a minimum,
* relatively free of PHP notices and warnings.
*
* - WP_DEBUG: This turns on debugging mode.
@norcross
norcross / email-address-login.php
Last active September 5, 2024 01:48
allow email address to be used as login name
<?php
add_filter ( 'authenticate', 'rkv_login_options', 20, 3 );
function rkv_login_options( $user, $username, $password ) {
if ( is_email( $username ) ) {
$user = get_user_by( 'email', $username );
}
if ( $user ) {
@amdrew
amdrew / gist:98bec268c6576a55727b
Created May 27, 2014 05:46
AffiliateWP - Check if the currently logged in WordPress user is an affiliate
<?php
// Check if the currently logged in WordPress user is an affiliate
if ( affwp_is_affiliate() ) {
// Do something
}
@zanematthew
zanematthew / gist:3199265
Created July 29, 2012 14:38
WordPress Update Meta Key
<?php
/**
* Rename meta keys
* Usage: update_meta_key( 'old_key', 'new_key');
*/
function update_meta_key( $old_key=null, $new_key=null ){
global $wpdb;
$query = "UPDATE ".$wpdb->prefix."postmeta SET meta_key = '".$new_key."' WHERE meta_key = '".$old_key."'";