Display Post Form through Shortcodes
-
Hi,
I want to make the Activity Post Form accessible to WordPress pages using short codes.
The reference to the post form can be found here: html/wp-content/plugins/buddyboss-platform/bp-templates/bp-nouveau/buddypress/activity/index.phpWhich contains this…
<?php /** * The template for BuddyBoss Activity templates * * This template can be overridden by copying it to yourtheme/buddypress/activity/index.php. * * @since BuddyPress 2.3.0 * @version 1.0.0 */ ?> <?php bp_nouveau_before_activity_directory_content(); ?> <?php if ( is_user_logged_in() ) : ?> <?php bp_get_template_part( 'activity/post-form' ); ?> <?php endif; ?> <?php bp_nouveau_template_notices(); ?> <?php if ( ! bp_nouveau_is_object_nav_in_sidebar() ) : ?> <?php bp_get_template_part( 'common/nav/directory-nav' ); ?> <?php endif; ?> <div class="screen-content"> <?php bp_get_template_part( 'common/search-and-filters-bar' ); ?> <?php bp_nouveau_activity_hook( 'before_directory', 'list' ); ?> <div id="activity-stream" class="activity" data-bp-list="activity"> <div id="bp-ajax-loader"><?php bp_nouveau_user_feedback( 'directory-activity-loading' ); ?></div> </div><!-- .activity --> <?php bp_nouveau_after_activity_directory_content(); ?> </div><!-- // .screen-content -->
I want to reuse the following code which can also be found in the file above:
<?php if ( is_user_logged_in() ) : ?> <?php bp_get_template_part( 'activity/post-form' ); ?> <?php endif; ?>
So I created a short code in functions.php in the child theme, which I use to place in WordPress pages as a shortcode…
function InsertPostForm() { if ( is_user_logged_in() ) : php bp_get_template_part( 'activity/post-form' ); endif; } add_shortcode('InsPostForm', 'InsertPostForm');
However, my solution does not work. I am very desperately in need of a solution. Please note my knowledge of PHP is very limited.
Thank you!
- You must be logged in to reply to this topic.