0

I am trying to add a Send email tab to all user's profile using hook_menu(). However, it's not working. My custom module name is page_callback_test and here's the code in it.

function page_callback_test_menu() {
$items['/user/%user/email_user'] = array(
    'title' => t('Send email'),
    'page callback' => '_send_email_touser',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_LOCAL_TASK,
    );


return $items;

}

function _send_email_touser(){
    return t("let's send email to this user");
}

1 Answer 1

1

Your code works - just remove the first forward-slash from the URL you are passing to hook_menu().

Correct: $items['user/%user/email_user'] = array(
Not correct: $items['/user/%user/email_user'] = array(

Be sure to clean cache after you update this.

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.