-
I’d like to add the ‘view user profile ‘ , and ‘ Follow ‘ buttons to other areas of my site.
Thankssorry for duplicate post under test account
Also , how to use the ‘heart’ like on other pages. Basically when someone views an image, I want the heart to be on that post page also , not only in the rollover.
Thanks!
For follow buttons can do something like
<?php echo $userpro_social->follow_text($user_id_here_you_want_to_follow, get_current_user_id()); ?>
follow_text(‘User id that you want to follow’, ‘Your user id’)
Thanks Kabadabra,
That’s useful but I need the code to do this on single pages dynamically. Do you know a way I can do this on single posts using the author name.Thanks
For you posts/pages get the author id by using something like
$author_id = the_author_ID();
Then for the follow button you can do
echo $userpro_social->follow_text($author_id, get_current_user_id());
This will allow users to follow the author of the post/page.
UserPro uses proper WordPress structure so the normal WordPress codex functions work as normal.
WordPress info on Author ID: http://codex.wordpress.org/Function_Reference/the_author_ID
Thanks for your help so far!,
Author ID gets the ID, let’s say poster is ID 8 ,
Does userpro require that ID ? or the actual name of the user.I paste this inside the single.php
<?php echo $author_id = the_author_ID(); ?>
<?php echo $userpro_social->follow_text($author_id, get_current_user_id()); ?>but when I click follow it adds a blank follower to my follow list , but not the right one, then removes it when I refresh.
Change
<?php echo $author_id = get_the_author_ID(); ?>
to just
<?php $author_id = get_the_author_ID(); ?>
We are setting a variable here, not printing out the $author_id.
You may also want to add in
PHP12345if($author_id != get_current_user_id()) {//do code here}This will prevent the follow button to be displayed if you are logged in and it’s your own post as well.
so you full code would be:
PHP1234567$author_id = get_the_author_ID();$current_user_id = get_current_user_id();if($author_id != $current_user_id) {echo $userpro_social->follow_text($author_id, $current_user_id);}I feel like we are almost there. 🙂
I added that code, however the user does not get added to my follow list. I will keep trying things.Cool…
sorry please change
$author_id = the_author_ID();
to
$author_id = get_the_author_ID();
Made a mistake with the author ID retrieval method
Thanks! This works now. It’s perfect.
Now to figure out the other stuff. This is a great addition though, makes the site much more usable.
Thanks againNot a problem 🙂
For future support requests from the developer just remember to enter in your Envato purchase code in your profile 😉
<?php echo $author_id = get_the_author_ID(); ?>
<?php echo $userpro_social->follow_text($author_id, get_current_user_id()); ?>it’s not work. 🙁 any idea?
You must be logged in to reply to this topic.