Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Show only first post in any topic
Avatar
Rick Yaeger
Member
Free Members
sp_UserOfflineSmall Offline
Jan 16, 2015 - 5:18 pm

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?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 16, 2015 - 8:58 pm

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?

Avatar
Rick Yaeger
Member
Free Members
sp_UserOfflineSmall Offline
Jan 16, 2015 - 9:02 pm

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.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 16, 2015 - 10:55 pm

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/simpl.....ld-themes/

your own theme see:  https://simple-press.com/docum.....g-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...

Avatar
Rick Yaeger
Member
Free Members
sp_UserOfflineSmall Offline
Jan 17, 2015 - 4:06 pm

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.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 17, 2015 - 4:21 pm

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

Avatar
Rick Yaeger
Member
Free Members
sp_UserOfflineSmall Offline
Jan 17, 2015 - 4:30 pm

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

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 17, 2015 - 4:31 pm

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

so it gives you what you want?

Avatar
Rick Yaeger
Member
Free Members
sp_UserOfflineSmall Offline
Jan 17, 2015 - 4:34 pm

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?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 17, 2015 - 4:35 pm

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

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626