php – Add any username as link prefix and show data from that specific user’s profile on wordpress pages – with no login required

Question

Example: www.example.com/johndoe/sample-page/

User with username “johndoe” has

  1. Name field value of “John Doe”
  2. E-mail field value of “johndoe@email.com”
  3. Facebook field value of “facebook.com/johndoe”
  4. Address field value of “Main street 47 ”

Show this values on Sample Page via shortcode
[userdata username={read_from_url} field=email]

Once opened, save this username in a cookie and redirect the visitor:
www.example.com/sample-page/ –> www.example.com/username/sample-page/

Add that USERNAME to all internal links to avoid redirects (from there on every active link on the website to contain the prefix)

Live example with the same functionality on another wordpress site: https://eqology.com/15499949/webshop/our-products-en/omega-3-en/
(Check CTRL+U to see all internal links contain the username/id prefix)

I’ve tried creating a rewrite tag and a rule for it to be put in a url param
add_rewrite_tag('%username%', '([^&]+)', 'username=");

Then use URL Params shortcode
[urlparam param=”username’] but I know it’s not suppossed to work this way 😀

0
Csaba.io 4 weeks 2022-11-02T17:03:12-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse