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.

front end post submission access their posts

Home Forums Community Forum front end post submission access their posts

This topic contains 6 replies, has 2 voices. Last updated by  David Welch 4 years, 9 months ago.

Topic Author Topic
Posted: Wednesday Apr 11th, 2012 at 6:08 pm #10615

great plugin, upgrading as we speak to the pro version, only to do the decent thing and pay for this great plugin.

we allow front end post submission, thats working, but, one thing is that once a user posts their entry they cannot view their own entry (unless a paid member), anyone know a bit of custom api type code that would allow posts to be secured but accessible to the post author?

thanks in advance
Darren

List Of Topic Replies

Viewing 6 replies - 1 through 6 (of 6 total)
Author Replies
Author Replies
Posted: Wednesday Apr 11th, 2012 at 10:30 pm #10623
David Welch
Username: dwbiz05

You can do this by adding a function to your functions.php file in your theme or to a new file under wp-content/mu-plugins/s2hacks.php (you may need to create this directory and file).

The Function:

<?php

function my_post_filter($bool, $vars=array()){

	//This checks to see if the user is logged in and if the user is the author. 
	if(is_user_logged_in() && $vars['post']->post_author == S2MEMBER_CURRENT_USER_ID){
		//This tells s2member to ignore post access checking
		return true;
	}
	else {
		//This tells s2member to continue with post access checking
		return false;
	}
	
}
add_filter('ws_plugin__s2member_check_post_level_access_excluded','my_post_filter',10,2); //hooks into the s2member filter.

?>

Hope that helps,

Dave

Posted: Thursday Apr 12th, 2012 at 2:44 am #10627

thanks Dave, is that directory correct, mu-plugins? does that need to be under teh s2member plugin?

I created the dir structure as you outlined above and put teh file in place but it doesn’t work.

thanks
Darren

Posted: Thursday Apr 12th, 2012 at 2:47 am #10628

it did how ever work popping it into the functions file :) brilliant, thankyou so much

Posted: Thursday Apr 12th, 2012 at 2:48 am #10629

sorry, take that back, no it didnt, now any user can access it.

Posted: Thursday Apr 12th, 2012 at 2:49 am #10630

take that back again, wroking, the user i was logged in with was admin which is a higher level so allowed to see, all appears to work :-)

Posted: Thursday Apr 12th, 2012 at 9:46 am #10656
David Welch
Username: dwbiz05

Yes, admin will trigger a false if someone else created it. However, the rest of the post access routine will give the admin access based on the admin role.

No problem, I hope it works well for you.

Dave

Viewing 6 replies - 1 through 6 (of 6 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.