Custom ID for [e2pdf-user]

WordPress
9 March, 2022 00:51:04
aentipufi
Topics: 3
Messages: 5
Hello,
I have deleted previous users from the WP database and unfortunately forgot to reset the auto-increment values, so now the first userid in the database is 2094. So when I use the [e2pdf-user] shortcut it displays 2094 which is correct. I would like to substract 2093 from all [e2pdf-user] IDs to properly display the user number. Unfortunately if I add [e2pdf-user]-2093 it will not work, and such displaying 2094-2093 instead of 1.
Please advise.

Kind regards,
Alex
9 March, 2022 03:46:27
E2Pdf
Support
Topics: 7
Messages: 3177
Hi,

E2Pdf pulls data directly from WordPress functionality and unfortunately E2Pdf currently doesn't support inline math operation. The best way will be to correct that data in database however as an alternative you can try to use PHP hook added to theme functions.php or as PHP Snippet:

You will also need to replace [e2pdf-user] to [e2pdf-user key="ID"] inside E2Pdf Template.


add_filter('e2pdf_model_shortcode_e2pdf_user_response', 'e2pdf_model_shortcode_e2pdf_user_response_ump', 10, 3);

function e2pdf_model_shortcode_e2pdf_user_response_ump($response, $atts, $value) {
if (isset($atts['key']) && $atts['key'] == 'ID') {
if ($response) {
$response = intval($response) - 2093;
}
}
return $response;
}


We remain at your service.
We would really appreciate your feedback at WordPress.org!