latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

WordPress Administrator role not recognised

Home Forums Community Forum WordPress Administrator role not recognised

This topic contains 2 replies, has 2 voices. Last updated by  Sebastiano 3 years, 8 months ago.

Topic Author Topic
Posted: Thursday Apr 18th, 2013 at 10:23 am #47784

I am using a theme called “The Gossip” have added code to my singlepost.php page so that is applied to all posts.

The code will allow S2Members above level 2 to see the entire post and users below level 2 to only see the first 5 sentences. This is working fine for all users except for users with the WordPress Administrator role who are being treated as a user below level 2. I thought that this would work as S2Members treats a WordPress Administrator as level4? The code is below:

if( current_user_is( 's2member_level2' ) || current_user_is( 's2member_level3' ) || current_user_is( 's2member_level4' ) ) {
						
						  the_content(__('Read More »', 'gp_lang'));
						
						} else {
						  	
						  	$sentences = textToSentence( get_the_content(__('Read More »', 'gp_lang') ) ); 
						  echo('<p>'.implode( ' ', array_slice($sentences, 0, 5) ).'..'.'</p>' );
							
						  	if ( current_user_is( 's2member_level1' ) )
							  	echo embed_it_get_snippet_content( 21831 ); 
							else
								echo embed_it_get_snippet_content( 21828 ); 

						}
  • This topic was modified 3 years, 8 months ago by  Bruce. Reason: Please put code in tags

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Thursday Apr 18th, 2013 at 11:35 pm #47846
Bruce
Username: Bruce
Staff Member

This is working fine for all users except for users with the WordPress Administrator role who are being treated as a user below level 2.

You need to use current_user_can(), rather than current_user_is().

See: Dashboard -› s2Member® -› API / Scripting -› Advanced PHP Conditionals

current_user_can() will pick up members that are s2Member Level * or higher. Administrators can access any level.

Posted: Friday Apr 19th, 2013 at 10:43 am #47877

That worked great thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.