I would like to offer the possibility to download a specific report for every user of my webpage. To do so, I wrote some PHP code which fills the builder's shortcodes with the usernames and displays them all on the same page.
Unfortunately, when I download a report, it will always take the variables of the last shortcode. See picture for example. (In the picture, the variable "Mitarbeiter" will always be filled with "User 3", altough I would want it to insert "User 1" in the first row, "User 2" in the second and so on)
Hi,
I would like to offer the possibility to download a specific report for every user of my webpage. To do so, I wrote some PHP code which fills the builder's shortcodes with the usernames and displays them all on the same page.
Unfortunately, when I download a report, it will always take the variables of the last shortcode. See picture for example. (In the picture, the variable "Mitarbeiter" will always be filled with "User 3", altough I would want it to insert "User 1" in the first row, "User 2" in the second and so on)
Is there a way to avoid this?
Thanks a lot.
Rafael
Hi Rafael,
Thank you for the purchase.
I didn't understand quite well how you populate "Mitarbeiter" fields? Dynamically with your PHP code or you set default values fro these inputs?
Can you please send me a link of your page where you have report so I can take a look at it.
Hi Milos, I very primitively get a list of the users and then insert the data into the shortcodes:
$month_ini = new DateTime("first day of last month");
$month_end = new DateTime("last day of last month");
$args = array(
'blog_id' => $GLOBALS['blog_id'],
'role__in' => array(Promoter, Berater, Administrator),
'exclude' => array(1,4,5),
'orderby' => 'ID',
'order' => 'ASC'
);
$users = get_users( $args );
foreach( $users as $user ){
echo '
[reportbuilder id=1 element="varInput" name="Mitarbeiter" text="Mitarbeiter" default="' . $user->display_name . '" class=""]
[reportbuilder id=1 element="varInput" name="Von (Datum dd.mm.jjjj)" text="Zeitspanne: Von " default="' . $month_ini->format('d.m.Y') . '" class=""]
[reportbuilder id=1 element="varInput" name="Bis (Datum dd.mm.jjjj)" text="Bis " default="' . $month_end->format('d.m.Y') . '" class=""]
[reportbuilder id=1 text="Bericht herunterladen" class="btn"]
[wpdatatable id=5 var1="' . $user->display_name . '" var2="' . $month_ini->format('d.m.Y') . '" var3="' . $month_end->format('d.m.Y') . '"]<br>
';}
Hi Rafael,
Your website requires login and I can't see your page. Do you have problem with your custom code or problem is with generating reports?
Hi Milos,
i solved the Problem by generating a personal page for every user and show user-specific content only.
Thanks for your help