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.

php conditionals in bbpress topics

Home Forums Community Forum php conditionals in bbpress topics

This topic contains 3 replies, has 2 voices. Last updated by  Bruce 3 years, 11 months ago.

Topic Author Topic
Posted: Tuesday Jan 22nd, 2013 at 9:50 am #38955
Andaluzo
Username: andaluzo

Hi,

I try to get

<?php if (current_user_can("access_s2member_level1")){ ?>
   Some content for Members who are logged in with an s2Member Level >= 1.
<?php } else { ?>
   Some public content.
<?php } ?> 

work in bbpress topics.

The Code works fine on Pages on my WP installation, but does not on BBPress Topics.

Is there a manual for get the code running in BBPress ?

Thanks

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Wednesday Jan 23rd, 2013 at 12:28 pm #39185
Bruce
Username: Bruce
Staff Member

Thanks for your inquiry.

The way that his works depends on what PHP Execution plugin you are running. I can tell you that most PHP Execution plugins run off of the WordPress Filter the_content.

Likely what’s happening is that bbPress’s topics are not filtered using the_content, and therefore your PHP Execution plugin is not actually given access to these posts. bbPress does support custom templates, however. You may be able to have this content filtered through this template.

See: bbPress » Codex Home » Step-by-Step Guide to Creating a Custom bbPress Theme

Posted: Wednesday Jan 23rd, 2013 at 3:40 pm #39228
Andaluzo
Username: andaluzo

Hi Bruce,

I use the following plugin

http://wordpress.org/extend/plugins/exec-php/

Should i change to another?

I do not get the hint why I should change the template, how would that solve the Problem?

Thanks

Posted: Wednesday Jan 23rd, 2013 at 5:07 pm #39239
Bruce
Username: Bruce
Staff Member

Thanks for the follow-up.

I use the following plugin

http://wordpress.org/extend/plugins/exec-php/

Should i change to another?

You may be able to change to another PHP Execution plugin that does support bbPress topics. I can’t think of any that do, but you may be able to find one.

I do not get the hint why I should change the template, how would that solve the Problem?

As I mentioned, PHP Execution plugins will normally execute PHP by hooking into WordPress through the the_content filter. If you were able to wrap the portion of the template that should be checked for PHP code, you can then wrap it in apply_filters('the_content', 'The content goes here'), and that section of the page would then have PHP Execution enabled.

See: WordPress -> Plugin API -> Filter Reference

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