1

Into a user profile page I provide a personal contact to conact the profile woner and that contact form is loaded like this:

$recipient = user_load(array('uid' => $fptr->uid));
$output .= drupal_render(drupal_get_form(
    'contact_personal_form', $recipient));

The form shows up nicely and all is well so far. While testing this form after sending 5 test messages I get the warning that I cannot send more than 5 messages within 1 hour. That is OK, but it seems the access to the entire user profile page is denied and it screws up the page layout.

Is there any way I can just lock the personal contact form instead of locking the entire profile page?In other words, is there a way to check if an anonymous user can send a personal message, and based on that check to show or hide just the message form?

Thanks for your help, also I hope that is easy to accomplish:-)

1 Answer 1

2

You need to check for flood before rendering the contact form

global $user;
// Check if flood control has been activated for sending e-mails.
$limit = variable_get('contact_threshold_limit', 5);
$window = variable_get('contact_threshold_window', 3600);
if (!flood_is_allowed('contact', $limit, $window) && !user_access('administer contact forms')) {
// Don't display forms
}
else {
  $recipient = user_load(array('uid' => $fptr->uid));
  $output .= drupal_render(drupal_get_form(
  'contact_personal_form', $recipient));
}
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.