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 11th, 2011, 8:52 pm

Just submitted a request on your site, @Bruce C

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

Re: Displaying User Role on the Site

Postby Bruce C » December 11th, 2011, 8:53 pm

Yup, I got it.

You can expect a reply within 2-3 days
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Displaying User Role on the Site

Postby peeld » December 11th, 2011, 8:55 pm

As my s2member site gets bigger, I have less time for this stuff; better left to the experts ;) Time = $ for everybody!

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

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 12th, 2011, 11:22 am

@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?
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby Bruce C » December 12th, 2011, 11:31 am

You need to make a mu-plugins folder, and put s2-hacks.php there.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 12th, 2011, 11:44 am

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.
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby Bruce C » December 12th, 2011, 11:47 am

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?
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Displaying User Role on the Site

Postby Bruce C » December 12th, 2011, 11:48 am

It's probably getting a null value because there is no user with the id '1' on your site.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Displaying User Role on the Site

Postby Bruce C » December 12th, 2011, 11:56 am

You need to download WP-Show ID's, and find your ID, and substitute it for 1 in the function I posted.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 12th, 2011, 12:00 pm

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.
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 12th, 2011, 12:06 pm

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?
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby Bruce C » December 12th, 2011, 12:58 pm

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.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 12th, 2011, 2:20 pm

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?
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 14th, 2011, 12:59 am

Anymore alternatives?
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 14th, 2011, 7:47 pm

bump!
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 15th, 2011, 3:07 am

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%29

Change $user_id for the actual var that has the ID of user you want the role of.

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 15th, 2011, 1:00 pm

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.
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

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

I tried any of the code in there, it seems nothing is working on get_user_field anywhere on my site..how come? =/
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 16th, 2011, 3:30 pm

bump! still need help.
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby Bruce C » December 16th, 2011, 4:59 pm

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.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Displaying User Role on the Site

Postby s2pidkaspr » December 16th, 2011, 8:12 pm

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?
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 18th, 2011, 5:43 am

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_in
viewtopic.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 ).
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 18th, 2011, 2:38 pm

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...
User avatar
s2pidkaspr
Registered User
Registered User
 
Posts: 48
Joined: August 6, 2011

Re: Displaying User Role on the Site

Postby peeld » December 18th, 2011, 7:23 pm

I contacted Bruce C to do a custom coding job on this for me; still waiting to hear from him.
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, 11:30 am

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 :)
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