I'm building a room letting website. Next to every advert is a send user private message button.

If the room is no longer available. I want to replace the button with the message "Sorry room no longer available" how can I do this please?

Many Thanks for your help Charles

1 Answer 1


You can use hook_form_alter. Find your form name and use the code below (form api doc).

function yourmodule_form_alter(&$form, &$form_state, $form_id) {
$form['mymessage']= array(
   '#type' => 'markup',
   '#markup' => 'sorry , no one available in room',
   '#weight' => 0,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.