• Resolved clausfaber

    (@clausfaber)


    I was wondering if it is possible to customize the user profile (I believe generated by profile.php).

    What we need is: the display of a button with a custom URL, which contains the name of the displayed user.

    1. I managed to make a new profile-2.php
    2. I can select it in the UM settings
    3. The new profile does not display yet, but that can be a cache issue.

    I don’t understand the logic of how profile.php generates its content, so I don’t know how to add a custom code to the table. Any help is appreciated!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • @clausfaber

    No you can’t replace or modify UM core scripts for customisations, use the UM hooks instead, which will give you secure UM updates in the future.

    See some examples here: https://docs.ultimatemember.com/collection/28-for-developers

    • This reply was modified 3 years, 9 months ago by missveronica.
    Thread Starter clausfaber

    (@clausfaber)

    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.
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @clausfaber

    um_user won’t be changed as it is a core function of UM plugin.

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hey there!

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. 🙂

    Regards,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘modify profile.php: how?’ is closed to new replies.