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.

Articles/Page content : visible in part only

Home Forums Community Forum Articles/Page content : visible in part only

This topic contains 10 replies, has 2 voices. Last updated by  Andy M. 4 years ago.

Topic Author Topic
Posted: Wednesday Dec 19th, 2012 at 7:35 pm #35106
Andy M.
Username: skyfox360

A.R
Participant December 19, 2012 at 5:13 am Permalink: #31752

Hello,

is it possible to set a page or a post in order that only a short part is visible for the public and then,

by clicking on a ‘Read More’ button for example, they would access to the whole content if they are logged

as an authorised user ? Like in some newspaper that have an internet version,

and only the registered users can read the whole article.

So I am wondering if this feature can be set on a WP blog website ?

Thanks a lot !!

A.

List Of Topic Replies

Viewing 10 replies - 1 through 10 (of 10 total)
Author Replies
Author Replies
Posted: Thursday Dec 20th, 2012 at 3:06 am #35125
Andy M.
Username: skyfox360

I do ask how we can integrate the shortcodes on portions of text in a page that has tabulations or accordeons text.

Example of the original page :
http://www.photographes-france.net/blog/medias-integration-contenus-textuels-en-tabulation/

4 tabs for 4 differents content.

If now, I want that these 4 tabs becomes visible for 4 different level of users, I have to add the shortcode, but where exactly please ?

Here is my text but non effective as the text content disappear !

[s2If !current_user_can(access_s2member_level0)]

Le Dr Patrick Métais est médecin interniste, gériatre et responsable de la mise en œuvre de nombreux établissements porteurs de projets innovants.

[/s2If]

I do not know where to place the [s2If] and [/s2If] codes. Outside the DIV ?

Shortcodes can be integrated on the visual or the text panel, the same way ?

Thanks for your kind help !!!

A.

Posted: Thursday Dec 27th, 2012 at 11:57 pm #35595
David Welch
Username: dwbiz05

I’m not sure if this is what you are trying to do, but take a look at the solutions I offered here:
http://www.s2member.com/forums/topic/allowing-non-members-to-read-a-bit-more/

Here is the synopsis:
Add this to your theme’s functions.php file:

add_shortcode('dw-post-more','dw_post_more');

function dw_post_more($atts,$content){
	extract(shortcode_atts(array("level" => 0),$atts));
	
	if(current_user_can("access_s2member_level".$level)){
		return do_shortcode($content);
	}
	else {
		return '<a href="'.S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL.'">Get Access To More Of This Content</a>';
	}
}

Then wrap your “hidden” part with this shortcode.. like this:

This is the public content.
[dw-post-more level="0"]
This is the private content. You can change the level to match whatever level should have access to the info.
[/dw-post-more]
This is public info after the private info.

Hope that helps,

Dave

Posted: Saturday Dec 29th, 2012 at 2:33 am #35694
Andy M.
Username: skyfox360

Sir,

here is my fonctions.php file. I would like to know where to place this slice of code in it.
In betwwen the

0),$atts));

if(current_user_can(“access_s2member_level”.$level)){
return do_shortcode($content);
}
else {
return ‘Get Access To More Of This Content‘;
}
}
?>

Posted: Saturday Dec 29th, 2012 at 3:18 am #35695
Andy M.
Username: skyfox360

PUBLIC TEXT
This is public info before the private info.

[dw-post-more level=”0″] PRIVATE TEXT [/dw-post-more]

This is public info after the private info.

——————————————–

Question 1 :
When I create a post with a part of private text, only visible for specific user, do I have to let the Post Level Restriction scrolling options empty ? I guess that if we input a level for the whole post or pages, it will hide the whole content and not a portion of it as requested, right ?

Question 2:
What mean this shortcode ? [dw-post-more level=”0″]
The text coming after can be seen for users belonging to level 1, 2 or 3 but not 0 ?

So this would be correct ?
[dw-post-more level=”1″]TEXT AVAILABLE FOR USER BELONGING TO LEVEL 2 [/dw-post-more]
[dw-post-more level=”2″]TEXT AVAILABLE FOR USER BELONGING TO LEVEL 3 [/dw-post-more]

Question 3:
If i give you an admin user, could you login and make a sample on a post or a page with public and private text ?
I already have the users created and a specific level for each of them.

Thanks for your help,

Andy

Posted: Saturday Dec 29th, 2012 at 3:31 pm #35737
David Welch
Username: dwbiz05

The function can go anywhere in your functions.php file as long as it’s before the last

?>

1. I’m not sure quite what your asking, but if you use the s2member setting for the page/post restrictions, it will hide the whole page/post. This function only hides the part in the middle of your shortcode tags.

2. Yes, that is exactly how it works!

3. It looks like you have the hang of it, but if you need me to, I can take a look.

Dave

Posted: Sunday Dec 30th, 2012 at 10:03 am #35797
Andy M.
Username: skyfox360

Dave,

give me an email as I will not drop an admin account on the forum !

I send you this in the day.

I have several pages and posts ready for splitting the text with both public part and private part.

Thanks for you help.

A.R

Posted: Sunday Dec 30th, 2012 at 7:22 pm #35830
David Welch
Username: dwbiz05

If you click on my username, I have my email listed in my “about me” text.

Dave

Posted: Monday Jan 7th, 2013 at 10:11 am #36459
Andy M.
Username: skyfox360

Hello

> I have created a special page with 4 parts of texts visible and each part is visible for a specific level of user
using the simple code : [dw-post-more level=”1″] / [dw-post-more level=”2″] / [dw-post-more level=”3″] / ..

Page is here : http://andrerizzotti.com/site_bebes_and_kids/blog/page-level-1-4-le-reportage/

> I would like to translate this part for text in french : Get Access To More Of This Content

> I would like that this part of text send the non logged user to the login page, but how ?

> If I translate the website in 2 languages, how can I get this sentence in both language according to the choice of the user ?

Thanks for your precisions,

A.

Posted: Monday Jan 7th, 2013 at 11:39 am #36467
David Welch
Username: dwbiz05

Questions 1 and 2 can be done together by changing the function from this:

return '<a href="'.S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL.'">Get Access To More Of This Content</a>';

to this:

return '<a href="'.S2MEMBER_LOGIN_PAGE_URL.'">YOUR FRENCH TEXT HERE</a>';

Now, if you want to make a choice, you would need to pull the user’s choice and then post the correct version… like this:

else {
		$fields = json_decode(S2MEMBER_CURRENT_USER_FIELDS, true);
		if($fields['language'] == 'french'){ //You need to replace language with your custom profile field name and 'french' with the value of the "french" option.
			return '<a href="'.S2MEMBER_LOGIN_PAGE_URL.'">YOUR FRENCH TEXT HERE</a>';
		}
		else {
			return '<a href="'.S2MEMBER_LOGIN_PAGE_URL.'">YOUR OTHER LANGUAGE TEXT HERE</a>';
		}
	}

I hope that makes sense.

Let me know if you have any questions.

Dave

Posted: Tuesday Jan 8th, 2013 at 9:03 am #36573
Andy M.
Username: skyfox360

Where do I define the S2 Member Login Page please ?

Do I have to specifiy it directly on the fonctions.php file ? replacing the :

<a href="'.S2MEMBER_LOGIN_PAGE_URL.'">   by     </a><a href="//www.'">

or from the admin area ? In this case, would you be kind to tell me how ?

I need also to implement the redirection to the login page on specific ‘Read More’ button I could add on posts.
On many wordpress bases website, one can see a short part of text and then a read more button;
If the user click on it, I would like the non logged user to land on a page that invites him to log in to see the rest of the page. Only to log in, no monthly subscription in my case.

How can I do that ! (very important for me to understand how !)

THANKS !!!

A.

Thanks a lot,

A.

  • This reply was modified 3 years, 12 months ago by  Eduan. Reason: Added code tags
Viewing 10 replies - 1 through 10 (of 10 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.