(This post is following a previous question I asked and is related to ErikH's answer: https://civicrm.stackexchange.com/a/31142/6991)
Context: I want to send per email an attached amended certificate (document ID #73). I tried the API explorer v3 and for one test user (id #54) it worked fine. Why an attached .pdf? Because it's an insurance certificate and it's important for each one of the 4000 members to have it personalized, that they can't modify it because of a legal issue and that they can print it easily. Once the membership is manually approved (it will always stay this way, again for legal issues), I want the team of volunteers to have the simple option to send it.
I have 2 questions that are related to each other. I read the documentation but as far as I am not so familiar to code, I don't know exactly what to do.
Question #1: is it possible to include some code in an existing template with general purpose within Civicrm? and which code? (and of course how?...)
PHP?
$result = civicrm_api3('Pdf', 'create', [
'contact_id' => 54,
'template_id' => 73,
]);
or JavaScript
CRM.api3('Pdf', 'create', {
"contact_id": 54,
"template_id": 73
}).then(function(result) {
// do something with result
}, function(error) {
// oops
});
Question #2: for this action, the API needs a contact ID and it's obvious it makes no sense to set it this way. Is there awy to use some fuzion fields instead like the civitoken {user.id}? I tried this way and the API explorer returns an error message. Is it possible or not? Thanks for any help.