Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Good day, everyone:

I want to make wordpress to add the user's id number behind the ref's link string, so that, for example

<div class="toolsbutton"> 
<a href="http://mysite.com/mysite/page-">go this page</a>
 </div>

above code will be turning in to a link if the user id is 113 who clicked it, the address will become:

<a href="http://mysite.com/mysite/page-113">go this page</a>

Or, if you know an alternative to do so, please also let me know.

Generally, the purpose will be that a user will be directed to a page that with unified address but there will be a number equal to his id attached behind. every time, someone click the same link, in same page, will have the same effect on each user. When a user click it, will be the CURRENT USER, who is a registered user.

If anyone could tell me if I could create the page at the same time (if not exist), will be terrific!

Thank You

share|improve this question
    
I resolved it by using a php snippet plugin with Joshc's method –  Adam Mar 7 '13 at 15:37

1 Answer 1

up vote 2 down vote accepted

I guess maybe wp_get_current_user(); is what your looking for.

Something like this...

<?php $current_user = wp_get_current_user(); ?>

<a href="http://mysite.com/mysite/page-<?php echo $current_user->ID; ?>">go this page</a>

http://codex.wordpress.org/Function_Reference/wp_get_current_user

--

Actually I just re-read the question and maybe your not after the current user? You might want to elaborate the question more so we know the aim better.

share|improve this answer
    
I just bolded the info I updated. Thank you –  Adam Mar 6 '13 at 22:39
    
I guess if its the current user then my answer should the trick for the link - not sure how to create a page when the link is clicked tho –  Joshc Mar 6 '13 at 22:43
    
ok, thanks for that, its already good enough :) I am going to try it out and let you know further issue if there is any! –  Adam Mar 6 '13 at 23:16
    
Hi Joshc, I tried it, but I got Forbidden You don't have permission to access.... message. Do you know the correct method to apply this php code into my link? –  Adam Mar 7 '13 at 4:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.