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 (location.search != "")
{
	var x = location.search.substr(1).split(";")
	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,

add
cart/checkout/payment_details/credit
to your secure pages config

See this post for more details:
http://www.ubercart.org/forum/support/3380/failing_ajax_call_checkout_ssl

This also applies to any other payment method you have like:
cart/checkout/payment_details/other