Simple button to send users info to an email address What would be the best route to create a button on a page that once it's clicked, it sends an email to the administrator. Basically we are using the profile percentage completion module, and when a user is at 100% I want to display a button to opt into a program (the program meaning, it sends us all of their info in their drupal account)

It seems very simple, but I can't wrap my head around this. I could definitely add the logic to where if the profile is 100%, it will display a button. It's just the button functionality that I don't know how to do. Would I write a ajax hook? create a custom module?

Any help would be appreciated!

Thanks!
Hope this will help you.

In Drupal 7 you can use ctools for your requirement.


Just create a ctools link after 100% of profile completeness


Steps


Create link on 100% of profile completeness in the profile page

global $user;
ctools_include('ajax'); // Include the CTools tools that we need.
$entity_type = 'user';
$bundle = 'user';
if (module_exists('pcp')) {//check for 100% completeness
  $check_percentage = pcp_get_complete_percentage_data($entity_type, $bundle, $user);
  if (is_array($check_percentage)) {
    if ($check_percentage['current_percent'] == 100) {//100% of profile completed
      $mail_link = '';
      $mail_link = ctools_ajax_text_button(t("Send Mail"), "send_mail/nojs/$user->uid", t("Send Mail"));
      $link = "&#60;div id='#send-mail-" . $user->uid . "'&#62;"; //must have unique ID for replacement
      $link .= $mail_link;
      $link .= "";
    }
  }
  return $link;
}

Create menu for callback

$items['send_mail/%ctools_js/%'] = array(
  'title' => '',
  'page callback' => 'send_mail_link',
  'page arguments' => array(1,2),
  'access callback' => TRUE,
  'type' => MENU_CALLBACK,
);....
 return $items;

Send mail callback

function send_mail_link($js, $uid) {
  // Include the CTools tools that we need.
  ctools_include('ajax');
  $output = '';
  if(isset($uid)){
     $output .= '&#60;span class="mail-sent"&#62;Mail Sent&#60;/span&#62;';//without link
    //Code for sending an email to the administrator
    if(/* mail sent */){
       drupal_set_message('mail sent');
    }
  }
  if ($js) {
    $commands = array();
    $commands[] = ajax_command_html("#send-mail-$uid", $output);
    print ajax_render($commands);
    exit;
  }
  else {
    return $output;
  }
}