How to create simple confirmation page?

Drupal Answers Asked by MathewDragon on November 11, 2020

I want to create simple confirmation page. It means that after user change his email then he gets confirmation email with link to page. This link contains token. This link should open page for user with appropriate message (success or fail if token expired). I want to create simple module, But I don’t know which hook I should use to create this simple page. I must check this token by sending POST request to REST API before rendering page.

Any advice?

3 Answers

I wrote a blog post that you may find helpful. Good luck!

Answered by Purdy on November 11, 2020

function custom_menu() {
  $items = array();
  $items['admin/sendmail/%'] = array(
    'title' => t('Delete Entry'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('custom_confirm_form'),
    'access arguments' => array('send mail'),
    'type' => MENU_CALLBACK,
  return $items;

  function custom_confirm_form($form_state){
    return confirm_form($form, t('Are you sure you want to Send Mail?'), //message title
    'admin/send-mail', //redirect if cancelled
    t('Only say yes if you are really sure. Otherwise please click on cancel button.'), //message description
    t('Yes'), //confirm button text
    t('Cancel') //cancel button text

function custom_confirm_form_submit($form, &$form_state){
   //verify that the form was confirmed
  if ($form_state['values']['confirm']) {  

Answered by vishal sirsodiya on November 11, 2020

I suggest you use hook_user_update. Then you compare $account->mail and $account->original->mail. If the two email addresses are different, the user's email address changed. Next you generate the token and send an email to the user with a link to your page.

For the page, create a new menu entry via hook_menu and do the logic for the REST call there. You can get URL query parameters (especially the token) by using drupal_get_query_parameters. Maybe you should ensure that the token is unique and store it with the email address and the creation time (to check if it has expired) in the database.

The documentation for hook_menu (or 99% of all other modules available) should give you an example on how to use it.

Answered by schlicki on November 11, 2020

Add your own answers!

Related Questions

Social Media Embed Problems With the URL Embed module

0  Asked on November 30, 2021 by mckinzie25


Contextual links for node blocks

3  Asked on November 28, 2021


Set node to flagged by default

1  Asked on November 28, 2021 by andrew-morris


How do I replace drush_set_error()?

1  Asked on November 28, 2021


Get file ID and path to use in View template

1  Asked on November 25, 2021 by srodrig


How to use drupal_add_library with a module?

2  Asked on November 25, 2021


Ajax Form Not Working in some Some Regions

2  Asked on November 23, 2021 by sandesh-yadav


Facebook Album fetcher

1  Asked on November 23, 2021 by rajat-goyal


Condition on current moderation state

2  Asked on November 23, 2021 by paul-cappucci


how to apply a css code for a specific screen size

1  Asked on November 23, 2021 by coding-mv


hook_entity_predelete never called

0  Asked on November 23, 2021


User reference and Views 3 and Panels 3

1  Asked on November 21, 2021


MetaTag with JSON API won’t serialize

2  Asked on November 21, 2021 by johnventions


How to disable Rich Text Editor in image field caption ?

1  Asked on November 19, 2021 by lee-woodman


search block form not accepting special characters in drupal 7

1  Asked on November 19, 2021 by blueztechz


Unknown engine type outputformat

1  Asked on November 19, 2021 by gilles9999


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP