Skip to:
Content
Pages
Categories
Search
Top
Bottom

Error When Adding Custom Post Type to Activity Feed

  • @producist

    Participant

    Hello @imath,

    I was following your thread ( https://codex.buddypress.org/plugindev/post-types-activities/#adding-the-buddypress-support-and-specific-labels-at-post-type-registration) on how to add a custom post type support to the activity stream. I’m currently using WP 4.2.1 and BP 2.2.3.1, with a multisite — directory folder setup.

    I created a custom-bp.php file and uploaded it to my plugins folder and added the code you had for the CPT “pages” on the thread link above. This is the error I got:

    “Parse error: syntax error, unexpected T_FUNCTION in /nas/wp/www/staging/mcs2/wp-content/plugins/bp-custom.php on line 6”

    My goal is to add a custom post type called OFFER to the activity feed using your directions in the thread above. Can you help me with this please?

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • @producist

    Participant

    I also saw this about multisite installs in the thread you posted:

    “On multisite configurations, the post types that are registered on any sub-site will need to be registered on the root site in order to be listed in the Activity dropdown filters. That’s the case for the post and page post types”

    The site I’m trying to create a custom post type for is a subsite. I assume the Page Post Type is registered for the root install, so this shouldn’t be causing the problem right?

    @danbp

    Participant

    @producist

    don’t know what happens, but i just tested the latest snippet from the codex page and it works flawlessly on a multi and on a single install.

    Which PHP version is used on your site ?

    @producist

    Participant

    Hi danbp,

    The PHP version is 5.3.2. I’m using WPEngine as a host.

    @producist

    Participant

    I just tried adding the snippets and again and that problem isn’t happening anymore. However, the filter functionality isn’t working…

    See Screenshot —

    http://postimg.org/image/5ulodg0wz/

    Here’s the code I used….

    <?php
    // hacks and mods will go here ok
    
    // Don't forget to add the 'buddypress-activity' support!
    add_post_type_support( 'page', 'buddypress-activity' );
     
    function customize_page_tracking_args() {
        // Check if the Activity component is active before using it.
        if ( ! bp_is_active( 'activity' ) ) {
            return;
        }
     
        bp_activity_set_post_type_tracking_args( 'page', array(
            'component_id'             => buddypress()->blogs->id,
            'action_id'                => 'new_blog_page',
            'bp_activity_admin_filter' => __( 'Published a new page', 'custom-domain' ),
            'bp_activity_front_filter' => __( 'Pages', 'custom-domain' ),
            'contexts'                 => array( 'activity', 'member' ),
            'activity_comment'         => true,
            'bp_activity_new_post'     => __( '%1$s posted a new <a href="%2$s">page</a>', 'custom-textdomain' ),
            'bp_activity_new_post_ms'  => __( '%1$s posted a new <a href="%2$s">page</a>, on the site %3$s', 'custom-textdomain' ),
            'position'                 => 100,
        ) );
    }
    add_action( 'bp_init', 'customize_page_tracking_args' );
    
    ?>

    Is there anything I need to add or change in the above code in order to make PAGES show in the filter area?

    @imath

    Moderator

    Hi there,

    There’s a chance your theme hasn’t updated its templates. In order to have the activity dropdowns populated, please check your templates are up to date see https://codex.buddypress.org/themes/activity-dropdown-filters-in-templates/#use-bp_activity_show_filters-within-your-bp-default-child-theme

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Error When Adding Custom Post Type to Activity Feed’ is closed to new replies.
Skip to toolbar