Search
Other ReReplacer questions
Forum

Pick unique data corresponding to username

Edwin Form's Avatar Edwin Form
I need to customise a page so that when it is loaded by a particular user, rereplacer substitutes a link on the page with an external URL that is specific to that user.

On the page, there is a line that says...

* Away dates

...and this text is linked to a URL that opens a Google sheet with tickboxes against dates for letting our secretary know that the person involved will not attend the meeting on that date. We have sheets for every member, all linked to a master sheet that the secretary can access.

What I have to do is determine the logged-in user's username and rereplace the URL in the link it with the URL for his or her specific Google sheet.

Can anone point me in the right direction on how to do this?
Peter van Westen's Avatar Peter van Westen ADMIN
How many different users/urls will there be? Can the url be dynamically put together with the users data? Or do the urls contain some unique id that has nothing to do with the Joomla user?
Would you want to set the url for the user in a custom field in the user edit page?
Please post a rating at the Joomla! Extensions Directory
Edwin Form's Avatar Edwin Form
Thanks for looking at our problem.

Actually, we solved this ourselves by searching for code to place the logged-in username into the page - the code to find and echo the username to the page looks like this...

{source}
<?php
$user =& JFactory::getUser();

echo $user->username;
?>

{/source}

<p></p>

Then ReReplacer substitutes the username with the specific URL for that user's Google Sheet. We had to write individual substitution pairs for every user - when we tried to write a single substitution list, with comma separated entries for the users, the list became impossibly complicated to handle because the URLs for Google sheets are long. A mistake somewhere in the list would be really hard to find. 🙂

We also have one or two usernames that are common to the data in our website - it's Bible-based, so the name "Peter" is quoted many times in other pages, and "Chris" is the beginning of "Christ" and "Christian". This meant we had to restrict the operation of the ReReplacer codes to only to the new page and prevent it from looking in things like page titles etc.

Ed Form
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription