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.

Hook or Filter for Specific Post Restriction

Home Forums Community Forum Hook or Filter for Specific Post Restriction

This topic contains 2 replies, has 2 voices. Last updated by  Raam Dev 4 years, 8 months ago.

Topic Author Topic
Posted: Thursday Apr 26th, 2012 at 11:11 am #11946

Hi,

I want to add a conditional to test if something is true and then display a post regardless of the “specific post conditions” already set. For example, if $x=123 then ignore specific post restrictions and display post – don’t redirect to Options Page.

I think I need to modify or filter this …
ws_plugin__s2member_before_check_specific_post_level_access

I’ve set up mu-plugins/s2-hack.php and have the following template but I don’t know how to structure the hook or filter.

<?php
add_filter("filter_name", "my_filtering_function");
function my_filtering_function($original_value, $vars = array())
	{
		if($original_value !== "something I like")
			return ($my_custom_value = "My Filter works.");
 
		else # Return original value.
			return $original_value;
 
		# Optional. s2Member® passes you an array of defined variables.
		# print_r($vars); # Would give you a list of defined variables.
		# These are PHP variables defined within the scope of the Filter,
		# at the precise point in which the Filter is fired by s2Member®.
 
		# $vars["__refs"] are also included (with some Filters).
		# These are internal PHP variable references (very useful).
		# To learn all about references, please see PHP documentation:
		# http://www.php.net/manual/en/language.references.pass.php
	}
?>

Can you please provide an example?

Thanks,
Steinar

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Thursday Apr 26th, 2012 at 5:08 pm #11989

I figured it out.

In s2-hack.php I used the following code, which allows certain users to bypass S2Member altogether for any post level restrictions I have in place.

$a= "some variable, like a static IP address";
if ($a = "123")
add_filter("ws_plugin__s2member_check_post_level_access_excluded", "__return_true");
Posted: Thursday Apr 26th, 2012 at 8:11 pm #12012
Raam Dev
Username: Raam
Staff Member

Steinar, thank you for posting back with the solution! That’s absolutely correct. :)

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.