Support Forum

Show only first post in any topic

RY Rick Yaeger
Rick Yaeger
Member

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?

16 Answers

New Answer

MP Mr Papa
Mr Papa
Member

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?

RY Rick Yaeger
Rick Yaeger
Member

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.

MP Mr Papa
Mr Papa
Member

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…

RY Rick Yaeger
Rick Yaeger
Member

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.

MP Mr Papa
Mr Papa
Member

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…

RY Rick Yaeger
Rick Yaeger
Member

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!!

MP Mr Papa
Mr Papa
Member

oh, new file then… so yeah, have to put that… sorry…

so it gives you what you want?

RY Rick Yaeger
Rick Yaeger
Member

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?

MP Mr Papa
Mr Papa
Member

sorry, not following… Its showing instead of the first post?  or elsewhere on page?  do you have link to it?

RY Rick Yaeger
Rick Yaeger
Member

http://onequestioninterviews.com/dashboard/forum/interviews/paul-wesley/#p7

MP Mr Papa
Mr Papa
Member

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…

MP Mr Papa
Mr Papa
Member

yeah its an emember protected content message…

RY Rick Yaeger
Rick Yaeger
Member

It was WP-eMember’s doing. Simple:Press has be absolved of all charges.

-FIXED-

MP Mr Papa
Mr Papa
Member

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…