Page 2 of 4
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 11th, 2011, 8:52 pm
by peeld
Just submitted a request on your site, @Bruce C
Thanks,
Daisy
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 11th, 2011, 8:53 pm
by Bruce C
Yup, I got it.
You can expect a reply within 2-3 days
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 11th, 2011, 8:55 pm
by peeld
As my s2member site gets bigger, I have less time for this stuff; better left to the experts
![Wink ;)](https://www.primothemes.com/forums/images/smilies/icon_e_wink.gif)
Time = $ for everybody!
Daisy
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 12th, 2011, 11:22 am
by s2pidkaspr
@Bruce C
i don't have the /mu-plugins on my /wp-content folder. And I even tried to make a s2hacks.php and put it on my /wp-content/plugins directory and put on the code but it seems not working. =/
Any alternatives?
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 12th, 2011, 11:31 am
by Bruce C
You need to make a mu-plugins folder, and put s2-hacks.php there.
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 12th, 2011, 11:44 am
by s2pidkaspr
It seems to works now than before. But not really.
I have phpbb installed on my site and after putting your s2hacks.php code.
It gives me this error:
[phpBB Debug] PHP Warning: in file /home/www/MYSITE/wp-content/mu-plugins/s2hacks.php on line 6: Invalid argument supplied for foreach()
Mind please telling me what's wrong on line 6?
Thanks, i'm assuming were almost there.
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 12th, 2011, 11:47 am
by Bruce C
That would mean that the function is either getting a string, or it's getting a null value. Is it doing this whenever you try to call the function?
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 12th, 2011, 11:48 am
by Bruce C
It's probably getting a null value because there is no user with the id '1' on your site.
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 12th, 2011, 11:56 am
by Bruce C
You need to download WP-Show ID's, and find your ID, and substitute it for 1 in the function I posted.
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 12th, 2011, 12:00 pm
by s2pidkaspr
Like my admin ID?
Well, I tried using a member's ID, it works. But its showing "SUBSCRIBER" on all. Not each member's OWN status level.
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 12th, 2011, 12:06 pm
by s2pidkaspr
Ok I have found my Admin ID. And replaced your code with it. Now, it is showing Administrator on ALL member's role statuses. I want it like show status of each members. Like for example, if the member is a regular member or a premium member, it will show that. How please?
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 12th, 2011, 12:58 pm
by Bruce C
If you would like to show the current logged-in user's status, just use the code Eduan posted, otherwise, if you're looking to do something like what Daisy put, you will need to use that code, and pass the ID dynamically.
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 12th, 2011, 2:20 pm
by s2pidkaspr
The thing is, its not showing what i wanted. It is showing the admin ID's status which is Administrator. Not each individual's status. Do you get what I mean?
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 14th, 2011, 12:59 am
by s2pidkaspr
Anymore alternatives?
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 14th, 2011, 7:47 pm
by s2pidkaspr
bump!
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 15th, 2011, 3:07 am
by Cristián Lávaque
If I understand correctly what's being requested here, I think this is what you need:
- Code: Select all
get_user_field ('s2member_access_role', $user_id);
viewtopic.php?f=40&t=12453&src_doc_v=111105#src_doc_get_user_field%28%29Change $user_id for the actual var that has the ID of user you want the role of.
I hope that helps.
![Smile :)](https://www.primothemes.com/forums/images/smilies/icon_e_smile.gif)
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 15th, 2011, 1:00 pm
by s2pidkaspr
Well it didn't help. I'm trying to display their status role on wordpress comments. Whereas each comments came from different authors, which I want whoever author is commenting to show their role titles as Administrator, or either of s2member level 1-4 ( based on their names of course ), for example, Silver Member, Gold Member...
And I also want it to show even if the visitor or comment viewer is logged in or logged out.
i'm NOT trying to make it display who the user that is currently logged in.
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 15th, 2011, 1:38 pm
by s2pidkaspr
I tried any of the code in there, it seems nothing is working on get_user_field anywhere on my site..how come? =/
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 16th, 2011, 3:30 pm
by s2pidkaspr
bump! still need help.
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 16th, 2011, 4:59 pm
by Bruce C
The problem lies in that it's not possible to display the user role unless you can pass the ID into it. So this particular customization is not possible without a large amount of code involved, in which you pick up the user ID or user login and then get the user role by ID.
That's what's going wrong.
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 16th, 2011, 8:12 pm
by s2pidkaspr
I still don't get it. Hmm, s2member works fine on my site, except for this code. Do you think you can help me do this?
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 18th, 2011, 5:43 am
by Cristián Lávaque
You'll need to edit the comments template and add this using a conditional that checks whether the visitor is logged in or not and then use a function to get the commenter's role.
http://codex.wordpress.org/Function_Ref ... _logged_inviewtopic.php?f=40&t=12453&src_doc_v=111206#src_doc_get_user_field%28%29 # $s2member_access_label = get_user_field ("s2member_access_label"); # An s2Member Membership Access Label ( i.e. Bronze, Gold, Silver, Platinum, or whatever is configured ).
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 18th, 2011, 2:38 pm
by s2pidkaspr
That code actually works, however, it is displaying the current logged in user's status...NOT each comment author's status....
For example, if the member is Gold Member, and i put the functionality on comments, it will display on every single comment of every authors....that's NOT what i'm trying to do. I want it like if the comment author is SILVER MEMBER, it will show on their comment and if the comment author is GOLD it will show them that...even if BOTH authors, post on the same page....
EDIT:
Also, I want the comment author to show their status (Gold, Silver, etc) on their comments, even if the MEMBER or VISITOR is logged out...
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 18th, 2011, 7:23 pm
by peeld
I contacted Bruce C to do a custom coding job on this for me; still waiting to hear from him.
Re: Displaying User Role on the Site
![Post Post](styles/custom/imageset/icon_post_target.gif)
Posted:
December 19th, 2011, 11:30 am
by s2pidkaspr
thanks i hope i can get this executed..
i really want this function to be done on my comments section, so that any member or even visitors can see if the comment author is an upgraded member or not based on their status..
thank you i will be waiting
![Smile :)](https://www.primothemes.com/forums/images/smilies/icon_e_smile.gif)