Thanks for the hints! Actually, by reading through them, I found a simple-and-maybe-dirty-but-working solution:
1) You can create other profile.php templates, that’s described here (so as you don’t need to mess with the default profile). You can put this profile-custom.php in your child theme so that it survives updates.
2) There are a few functions UM provides, which I can call (if it’s the profile page, where the libraries are loaded), among them: um_user($data), where $data is the field name in the sql database, like ‘display_name’. Then, as it will create an URL, I had to use the PHP funtion urlencode(), and that’s it (and for decoding on the other side, there is urldecode()).
–> with that, I created a custom code in my profile-custom.php, that did the job:
<div class="wp-block-button">
<a class="wp-block-button__link" href="/kontakt/?berater=<?php echo urlencode(um_user('display_name')); ?>">
Kontaktiere <?php echo um_user('display_name') ?></a>
</div>
On the landing page, I caught the variable in the URL with a WPForms form, which allows pre-filling form fields with query strings (described here).
The only downside: I could not place the code anywhere, but just at the beginning or the end of the part with the user data (as this is generated via the hooks).
It may be dirty as it will break as soon as an UM update changes behaviour of the function um_user() – I thinks that’ll be rather unlikely. And yes, hooks would be much better, but I’m not good enough to use them 🙁
-
This reply was modified 3 years, 9 months ago by
clausfaber.