August 2011

Assign Multiple Roles to User Programmatically in Drupal

$user = user_load(104);
$details = array(
		'uid' => $user->uid,
		'roles' => $user->roles
$details['roles']['7'] = 'FREE ORDER';
user_save($user, $details);

Get URL arguments using Javascript - $_GET Variables

if ( != "")
	var x =";")
	for (var i=0; i<x.length; i++)
		var y = x[i].split("=");
		alert("Key '" + y[0] + "' has the content '" + y[1]+"'")

Remove Newline from Text of Element / Convert \n to <br />

I was trying to write an if statement to perform some actions when a certain error message was present. I went round and round trying to figure out why the text of the element wouldn't match in my if statement. Turns out it was because there was a line break before the text which is considered content.

Drupal Administration Menu not displaying with custom theme

I have been creating a custom theme for my drupal website and I ran into this problem where the Drupal Administration Menu (module) disappears for custom themes that are not based on out-of-the-box themes. I did a lot of searching for a solution with no luck, so in the end I just ran through the code of existing themes to see what code is required for the menu. Hopefully I can help someone who may have the same question!

You basically need to have this code at the end of your page.tpl.php file:

Ubercart Credit Card Fields Not Showing at Checkout - Only Shows Loading Bar

Inside of Secure Pages Module,

to your secure pages config

See this post for more details:

This also applies to any other payment method you have like: