I want to add a link to a members' profile page. And need to do this inside the view. This works. But, it only works for the users with a single username. If any space is used, or if a user decides to register with email I have to filter out some characters and empty space. So for this I tried to add the following, but it fails:
<?php
$usrk=[form field key]; //username form field key
$clnusr=str_replace(' ', '', $usrk); //to remove the space
?>
<a href="https://www.site.com/members/<=? '$clnusr' ?>"> Profile</a>
Somehow, php does not work in editing section of the page content of the relevant view. Any help is appreciated.
How are you creating the link in a view? Are you embedding the PHP directly into the view HTML? Why are using user name instead of user id?
Hi Victor,
I am using the text box in view, and the html code for the link to the username site. So, it must be username, not ID. Without the php this code works. It opens the user profile page. But the problem is in wordpress username is not restricted. A user can leave space or use email address as username. There I get an error. I have to delete the space and @ and replace. with -.
You cannot use unsanitized text in a URL. To work in a URL, the special characters need to be converted to HTML entities. I suggest you store the sanitized user name in a hidden field and use that as your link. What you want to do will never work.
See this: https://formidableforms.com/knowledgebase/advanced/#kb-sanitize-url
Thanks Victor,
You were right. My approach was peculiar indeed. sanitize_URL did not work. But [x sanitize=1] worked perfectly.
Please login or Register to submit your answer