Skip to content

Instantly share code, notes, and snippets.

View evandonovan's full-sized avatar

Evan Donovan evandonovan

View GitHub Profile
@evandonovan
evandonovan / email_validate.php
Created May 13, 2010 03:57
code to validate email addresses (via MX address & PHP mail well-formedness rules)
/**
* Implements hook_user().
* Does advanced email validation.
*/
function revolven_user($op, &$edit, &$account, $category = NULL) {
if($op == "validate") {
if($error = adv_email_validate($edit['mail'])) {
form_set_error('mail', $error);
}
}
@evandonovan
evandonovan / taxonomy_token.module.php
Created April 28, 2010 15:38
taxonomy_token.module
<?php
// $Id
define(MODULE_DESCRIPTION, 'Provides tokens that will contain text when a taxonomy term is present. For use with taxonomy module.');
/**
* Implements hook_help()
*
*/
function taxonomy_token_help($path, $arg) {
@evandonovan
evandonovan / um_common_form-alter.php
Created April 3, 2010 15:09
example of various uses of hook_form_alter()
function um_common_form_alter(&$form, $form_state, $form_id) {
// hide split teaser on node forms
if (isset($form['#node']) && $form_id == $form['#node']->type .'_node_form') {
$form['body_field']['teaser_include'] = array(
'#type' => 'value',
'#value' => TRUE,
);
}
// user login block changes
elseif(($form_id == 'user_login_block')) {
@evandonovan
evandonovan / geocode_update.module
Created April 3, 2010 05:19
auto-updates geocodes using Google geocoder from location.module
<?php
// geocode_update.module
/**
* Implementation of hook_cron()
*
* Loads all the locations on the site which have invalid latitude/longitude,
* then uses the Google geocoder to update the latitude/longitude, if possible.
*/
function geocode_update_cron() {