PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Displaying User Role on the Site

s2Member Plugin. A Membership plugin for WordPress®.

Re: Displaying User Role on the Site

Postby peeld » December 19th, 2011, 12:26 pm

You should contact Bruce through his website - I'm sure if TWO people are willing to pay it'll be a little more likely he'll do it ;)
User avatar
peeld
Registered User
Registered User
 
Posts: 97
Joined: August 24, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 19th, 2011, 12:41 pm

well, im hoping i dont need to pay for this one, since i just want to know how to make it possible for s2member's functionality. It's not like a deep code query or something. LOL :P

Like I said, i just want to show off their s2member's level membership on wordpress comments, so that people who are either logged in members or just normal visitors would pass by reading a page with comments would see if those comment authors are upgraded members of the site or whatsoever. Its kind of just to make the comment section a little more detailed. :)
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby peeld » December 19th, 2011, 3:28 pm

I always want something for free :) But as my membership site grows, I find my time is $$ for this sort of stuff, I'm busy trying to teach on my site and the admin stuff is taking over :(
User avatar
peeld
Registered User
Registered User
 
Posts: 97
Joined: August 24, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 19th, 2011, 3:51 pm

yeah i know..though im seeking support for s2member only. its not like they have to do much work on my site. =/ but yeah, i really dont think what im asking is hard, its just that i cant find the right code for the functionality i want to work..
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby Cristián Lávaque » December 20th, 2011, 3:54 am

s2pidkaspr wrote: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...


You have to enter the comment author's ID to the function or it'll default to the current user (the one viewing it). It's in the function's documentation I linked to. Here's an example:

Code: Select all
$comment_author_access_label = get_user_field('s2member_access_label', $comment_author_id);
 


I hope that helps!
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 20th, 2011, 1:15 pm

Wow! It works now Christian. Thanks!
However, that code didn't worked itself, but the idea is.
Here's the code that actually make it work for me.

Code: Select all
$comment_author_access_label = get_user_field('s2member_access_label', ($comment->user_id));


So i put in

Code: Select all
<?php echo $comment_author_access_label = get_user_field('s2member_access_label', ($comment->user_id)); ?>


But anyway, thanks! Your code idea really helped out. :)

By the way, is there anyway to use "s2member_access_role" function that is not showing s2member_level1. As their role for upgraded members? I mean, I tried to use "s2member_access_role" on that code, and it shows admin as "administrator", editor as "editor", contributor as "contributor"...BUT, for members s2member level 1-4. It shows "s2member_level1", "s2member_level2" and so on.

Is it possible to make it show like what brand they have been named to? Like s2member_level1 as "Bronze", s2member_level2 as "Silver" and so on, while maintaining the administrator, editor, and contributor role for staff members?

Don't get me wrong though, "s2member_access_label" works just fine as I want it to be. But the admin show's the highest s2member_level (Gold), which is 4 on my site. I'm fine with that.

But just to make it more detailed, i want users to know who is commenting, it may be a staff or just a regular/upgraded member. You get what i mean? So i'm hoping to use "s2member_access_role" instead for that. If ever its not possible to do what i want, then i think i'm going to stick using "s2member_access_label" which works fine to me.

Again, thank you Christian and more power to s2member. :) Great support!
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby peeld » December 20th, 2011, 9:09 pm

This actually worked for you? It's returning PLATINUM MEMBER for everybody for me, which I assume is MY role....what other code was needed besides your snippet above?

Daisy
User avatar
peeld
Registered User
Registered User
 
Posts: 97
Joined: August 24, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 20th, 2011, 9:19 pm

what? you talking to me? =/
what do you mean it is showing platinum member for everybody to you?
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby peeld » December 20th, 2011, 9:30 pm

Heh - yes, talkin to you.

And yes, it's showing platinum member for everybody to me.
User avatar
peeld
Registered User
Registered User
 
Posts: 97
Joined: August 24, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 20th, 2011, 9:39 pm

how did you know the my site? i dont think i remember that i showed it here..hmmm...and i dont see you as my user in the site?

well, i think its working for me fine...may i know what is your username that is showing platinum for you?
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby peeld » December 20th, 2011, 9:47 pm

No, it's showing as platinum member on MY site for everybody :)
User avatar
peeld
Registered User
Registered User
 
Posts: 97
Joined: August 24, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 20th, 2011, 9:54 pm

ohhh...so not in my site? well..i dont know about that...
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby peeld » December 20th, 2011, 10:01 pm

That's why I'm asking you - did just that one line of code do the trick for you, or was there more code you had to put elsewhere, like in your s2-hacks file?
User avatar
peeld
Registered User
Registered User
 
Posts: 97
Joined: August 24, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 20th, 2011, 10:14 pm

no..that's just the code i put in..i tried the s2hacks file but since it doesn't work on me..i removed it..may i know whats your site?
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby peeld » December 20th, 2011, 10:49 pm

User avatar
peeld
Registered User
Registered User
 
Posts: 97
Joined: August 24, 2011

Re: Displaying User Role on the Site

Postby Cristián Lávaque » December 21st, 2011, 4:24 am

s2pidkaspr wrote:Wow! It works now Christian. Thanks!
However, that code didn't worked itself, but the idea is.


Of course, you had to use the actual variable with the user ID in your code. I just wrote that variable to make it descriptive of what it should be. I'm glad you figured it out and got it working.

s2pidkaspr wrote:But just to make it more detailed, i want users to know who is commenting, it may be a staff or just a regular/upgraded member. You get what i mean? So i'm hoping to use "s2member_access_role" instead for that. If ever its not possible to do what i want, then i think i'm going to stick using "s2member_access_label" which works fine to me.


For that you'd need to customize your code a little bit more... You could work with roles and then use an array to show the label you want for each, or check if the role has 's2member' in it and if so get the label.

s2pidkaspr wrote:Again, thank you Christian and more power to s2member. :) Great support!


Thanks for the kudos! Glad to help. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Displaying User Role on the Site

Postby Cristián Lávaque » December 21st, 2011, 4:37 am

peeld wrote:That's why I'm asking you - did just that one line of code do the trick for you, or was there more code you had to put elsewhere, like in your s2-hacks file?


Code: Select all
<?php echo $comment_author_access_label = get_user_field('s2member_access_label', ($comment->user_id)); ?>


That line of code in the comments loop should do it. Actually it doesn't even need the variable definition since it's being echoed and not used later. I only wrote that as an example earlier. You can do this:

Code: Select all
<?php echo get_user_field('s2member_access_label', $comment->user_id); ?>


If you want to distinguish the admin from the rest, you could do something like this (change the 1 for your actual user ID):

Code: Select all
<?php echo ($comment->user_id == 1 ? 'Administrator' : get_user_field('s2member_access_label', $comment->user_id)); ?>


I hope that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 21st, 2011, 11:50 am

@christian

This code

Code: Select all
<?php echo ($comment->user_id == 1 ? 'Administrator' : get_user_field('s2member_access_label', $comment->user_id)); ?>


Works better than what you told me to edit some codes and put arrays on. This code is exactly what i'm looking for. Works fine now. Thanks :)

Now, can you tell me, if how to write and add the code in there if I want another member to be named "Moderator?" and with multiple ID number? Is it possible too?
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby peeld » December 21st, 2011, 2:50 pm

I don't get how this is working for you - when I put it in either entry.php or comments.php on MY site, it still returns "Platinum Member" for everybody when I'm logged in as me, and when I log in as another user, it shows whatever THEIR member level is for everybody - it's still just returning the current user's status and not the comment poster's stats :(

Ace, you still here? My offer to pay for this is still out there, haven't heard from you...
User avatar
peeld
Registered User
Registered User
 
Posts: 97
Joined: August 24, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 22nd, 2011, 6:28 pm

@christian
you still there?


@peeld
probably it depends on what kind of theme you are using, because my comment section have been customed and its not even on entry.php and comments.php, i'm using different file path for my comments.
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby peeld » December 22nd, 2011, 8:38 pm

Maybe, but I doubt it - It shouldn't matter WHERE you put that code....it does work, in a manner of speaking; it doesn't break my site and it does return a value - it just returns the wrong value (the logged in user's role rather than the original poster's role).

Daisy
User avatar
peeld
Registered User
Registered User
 
Posts: 97
Joined: August 24, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 22nd, 2011, 9:58 pm

@peeld

well, have you tried different code approach on this topic? hmmm..may i see your page that has a comment section?
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby Cristián Lávaque » December 23rd, 2011, 3:00 am

s2pidkaspr wrote:Now, can you tell me, if how to write and add the code in there if I want another member to be named "Moderator?" and with multiple ID number? Is it possible too?


That's why I suggested the array for you, because you have more than one. One (e.g. Administrator) works fine with the condition I wrote for Daisy.

If you know a bit of PHP, you'll figure out how to do it for more than one person. Like I said, you can have an array where keys are the roles and values the labels, and use that.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Displaying User Role on the Site

Postby Cristián Lávaque » December 23rd, 2011, 3:05 am

peeld wrote:Maybe, but I doubt it - It shouldn't matter WHERE you put that code....it does work, in a manner of speaking; it doesn't break my site and it does return a value - it just returns the wrong value (the logged in user's role rather than the original poster's role).


Can you post inside code tags the contents of your file with the comments?
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 23rd, 2011, 12:02 pm

@christian
i see, but to confirm it, you are saying that's possible correct? if so then, ok...i'll try to figure that out...hey thanks again :) i really appreciate the help support...
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

PreviousNext

Return to s2Member Plugin

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron