Best practice to generate token for email action

Question

I need to make a custom link to confirm order from user by email.
This is the basic code :

private static function get_confirmation_link( int $recipient_id, array $params = null ){
    return home_url(sprintf( '?foo=%1$s&var1=%2$s&var2=%3$s&token=%4$s',
            '1',
            $recipient_id,
            $params['order-id'],
            $params['token'] //<-- how I generate this ?
        )
    );
}

Simple question : what is the best practice to generate token used in a link ?

Should I use wp_generate_user_request_key() and wp_send_user_request() ?

0
J.BizMai 1 month 0 Answers 8 views 0

Leave an answer