I am using the code below to edit the user profile "signature" but am getting error:
EntityMetadataWrapperException: Unknown data property signature. in EntityStructureWrapper->getPropertyInfo()

The code is:

$chosen_text="signature text";
$obj_signature = user_load(14);
$obj = entity_metadata_wrapper('user', $obj_signature);
$obj->signature = $chosen_text;
$obj->save();

Comments

ibexy’s picture

after searching I found this code that runs without error but it does not store the signature text. Instead it stores the word "Array" into the signature field:

$chosen_text="signature text";
		$obj = user_load(14);
		$edit = array(
		  'signature' => array(
			'LANGUAGE_NONE' => array(
			  0 => array(
				'value' => $chosen_text,
			  ),
			),
		  ),
		);
		user_save($obj, $edit);
Jaypan’s picture

Then you probably want this:

chosen_text="signature text";
$obj = user_load(14);
$edit = array(
  'signature' => $chosen_text,
);
user_save($obj, $edit);
ibexy’s picture

Worked like magic!
Thanks!

ibexy’s picture

How can I extract the signature into a string variable. I am using this code but its not working:

$obj_signature = user_load(14);
$signature_text = (string)check_markup($obj_shakasignatured->signature,  $obj_shakasignatured->signature_format);