1

I have implemented hook_menu() & called a function, but if I am trying to browse the page URL it's giving me "Page not found" error...

This is the code --

function user_type_registration_menu(){
  $items = array();
    $items['paypal/payment/ipn'] = array(
          'title' => t('Paypal Payment IPN'),
          'description' => t('Paypal Payment IPN'),
          'type' => MENU_CALLBACK,
          'page callback' => 'paypal_payment_paypal_ipn_callback',
          'access callback' => TRUE,
        );   
      return $items;
}
function paypal_payment_paypal_ipn_callback(){      
  dpm("here");
}

I have cleared the cahche too..so cahche can't be the problem...

  • have you created the callback function – Mohammed Shameem Feb 2 '13 at 11:08
  • Yes you can see the callback below... – RajeevK Feb 2 '13 at 11:08
  • have you tried returning something rather than just a dump of the variable. the menu call back should return something to be displayed. – Mohammed Shameem Feb 2 '13 at 11:17
  • I have succeed with checking the path in this way previously. I am not returning some thing here because I have to call this path from paypal return...and while doing that so...it's giving me same error... – RajeevK Feb 2 '13 at 11:28
  • Does it work if you set 'type' => MENU_NORMAL_ITEM ? – 2pha Feb 2 '13 at 14:41
2

With the code you posted you will get a blank page.

If you actually return something from your callback you will get a proper page, with no 404 error. A menu callback has to actually return something.

For example, this works:

function user_type_registration_menu() {
  $items = array();

  $items['paypal/payment/ipn'] = array(
    'title' => t('Paypal Payment IPN'),
    'description' => t('Paypal Payment IPN'),
    'type' => MENU_CALLBACK,
    'page callback' => 'paypal_payment_paypal_ipn_callback',
    'access callback' => TRUE,
  );

  return $items;
}

function paypal_payment_paypal_ipn_callback() {
  dpm("here");
  return 'test';
}

Also, make sure your module is named "user_type_registration" or else your menu hook will not get picked up.

  • Do you actually have to create a module for this or can you use your theme name? – AlxVallejo Jun 21 '14 at 14:53
  • You have to do hook_menu() from a module. – rooby Jun 21 '14 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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