Codekarate Content

By shane
Wed, 2011-06-08 15:52

Looking to do this in Drupal 7? See my updated post on how to Create a user account in Drupal 7 programmatically.

There have been a few situations in which I needed to create a user on a Drupal site based on some action. There are many other situations where this might be necessary so I put together a really quick example of how it can work. The code I have below is based heavily on the Ubercart code that creates new users when they purchase a product on an Ubercart powered Drupal site.

 
By shane
Mon, 2011-06-06 13:21

Adding Javascript to a Drupal 6 Module is a pretty simple process. This post can serve as a very simple primer to get you started.

It starts with implementing hook_init() in your .module file.

/**
 * Implements hook_init().
 */
function MYMODULE_init() {
  drupal_add_js(drupal_get_path('module', 'MYMODULE') .'/MYMODULE.js');
}

Then you will need to create a Javascript file called MYMODULE.js in your module folder. Drupal by default comes with the JQuery library. Your Javascript file should look similar to the one below:

By shane
Wed, 2011-05-25 23:26

As I write this, one of the websites I frequent for information is currently down. It is not uncommon for a website (or the server the website is on) to have a problem. I am not sure if the site is going through planned maintenance or if this is unexpected downtime, however it reminded me of a few things.

By shane
Mon, 2011-05-23 14:00

Drush is a very powerful command line utility for creating, managing, and maintaining your Drupal website. There are many things that you can do with Drush, but suffice it to say that if you develop/build Drupal websites and don't currently use Drush, you should most definitely check it out.

Note: If you are looking for help with Drush, check out this link - Drush: Getting started

By shane
Sat, 2011-05-21 00:31

After all the recent news dealing with Amazon or the Playstation network it may be hard for people to remain confident in the promise that the "cloud" has to offer. Day dreaming of people running around shouting "the sky is falling" seems to pop into my head. However, despite the fact that my confidence in the entire cloud movement is unwavering, I think the recent happenings bring out a lot of good points that people should know about. I have listed three that I believe in below:

Point 1: The cloud is not as secure as you think

By shane
Thu, 2011-05-12 12:58

If you need to alter a CCK form or perhaps a form being constructed by another module, sometimes using hook_form_alter() isn't enough. Sometimes the form has not yet been fully constructed and you need to modify a part of the form that is not yet available for you to touch.

This is where the After Build function comes in handy. It allows you to modify the form after the form is built and all the form_alter's have been run. Here is a simple code snippet on how to begin using the Drupal form after build function.

By shane
Wed, 2011-05-11 13:54

I recently ran into a problem on a site using the Organic Groups module in which I had to automatically create a group node when a user purchased a product with Ubercart. Below is the function I created to automatically create that Group node.

By shane
Thu, 2011-05-05 13:44

One of the things I am very interested in as of late, is coding efficiency. What do you do to increase your coding efficiency? Do you use specific tools or tricks?

I am going to go ahead and give away some of my secrets in hopes of helping others (and maybe to pick up some additional tricks).

My Development Environment

By shane
Tue, 2011-05-03 14:06

I recently was tasked with creating a Drupal 6 Ubercart Payment Gateway module. I started the task off looking over various contributed payment gateway modules for Ubercart as well as looking at the authorize.net payment gateway module that comes with the Ubercart module. What I found was that there are many techniques that developers use when building a payment gateway module. I am going to outline the ones that worked best for me.

By shane
Thu, 2011-04-07 23:08

I wanted to post an example of using hook_user to load some data to the user object. This simple example will just load an arbitrary value to the user object anytime a user object is loaded. You would typically load additional items by querying the database to get the information but for example purposes I just give it a simple value.

/**
 * Implements hook_user().
 */
function MYMODULE_user($op, &$edit, &$account, $category = NULL) {
  if ($op == 'load') {
    //typically you would use db_query or something similar here
    $account->mymodule_value = 'My value';
  }
}

Pages