Can’t seem to figure out how to configure Simple:Press to only show the first post of any topic in the forum to guests/logged-out members.
Can this be done?
Can’t seem to figure out how to configure Simple:Press to only show the first post of any topic in the forum to guests/logged-out members.
Can this be done?
not directly out of the box… but you can use our api and hooks to adjust the behavior…
are you able to create your own sp theme or a child sp theme,and make a few edits?
LOL… I don’t know, am I?
I suppose the answer is I have the opportunity to, but not the know how.
Any advice on where to learn such a thing?
Thanks for your help.
we recommend creating a child theme or your own theme otherwise if you upgrade our themes, you will lose any changes… both are quite easy to do…
child themes see: https://simple-press.com/simplepress-version-5-5-child-themes/
your own theme see: https://simple-press.com/documentation/codex/themes/theme-basics/creating-a-theme/
once you have a theme, then edit the spFunctions.php file in the templates directory of your theme… if you made a child theme, just create the file… then add this to it:
add_filter('sph_topicview_query', 'my_topic_view_query');
function my_topic_view_query($spdb) {
global $spThisUser;
if ($spThisUser->guest) {
$spdb->where.= ' AND (post_index = 1)';
add_action('sph_BeforeSectionStart_foot', 'my_ouput_notice');
}
return $spdb;
}
function my_ouput_notice() {
echo '<div class="spMessage">This is a message area - add what you want</div>';
}
that should do what you want…
I also took the liberty of adding a message section so you can output some text asking them to join or whatever… you can remove it if you like…
Thanks, Mr Papa.
Unfortunately it threw an error at me…
add_filter(‘sph_topicview_query’, ‘my_topic_view_query’); function my_topic_view_query($spdb) { global $spThisUser; if ($spThisUser->guest) { $spdb->where.= ‘ AND (post_index = 1)’; add_action(‘sph_BeforeSectionStart_foot’, ‘my_ouput_notice’); } return $spdb; } function my_ouput_notice() { echo ‘
Join the site to see more.
‘; }
Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at XXXXXXXX/wp-content/sp-resources/forum-themes/1Qi/templates/spFunctions.php:14) in XXXXXXXX/wp-content/plugins/wp-cart-for-digital-products/wp_eStore1.php on line 9
I’ve X’d out some sensitive information, but you should get the gist. Do you know what the problem might be?
Thanks again.
are you sure you did a code copy?? from the raw code? otherwise, you might have gotten wrongly encoded quotes… use the raw code button above the syntax highlighted code…
the code works for me… so thinking its cut and paste error…
You know what it was?
Fatal error on your part
…assuming I was bright enough to put <?php in the code myself on the first try.
I think it’s fixed now. Thanks Mr Papa!!
oh, new file then… so yeah, have to put that… sorry…
so it gives you what you want?
I think so. I have “Please Login to view this content. (Not a member? Join Today!)” showing up on the first post… is that Simple:Press? Or is WP-Member doing that?
sorry, not following… Its showing instead of the first post? or elsewhere on page? do you have link to it?
interesting… that is not simple press… also appears above the forum…
are you using a membership plugin to protect the page content? perhaps turn that off for the wp page the forum is on since the forum protects its own content using permissions…
It was WP-eMember’s doing. Simple:Press has be absolved of all charges.
-FIXED-
good deal… dont forget to update that message area (or remove) from below the post that is added with the code segment I gave you… might even copy in the text/problem-with-post-edit-buttontml from the emember message as it made the point pretty well…