Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom BuddyPress Template From a Plugin


  • chekerlamer
    Participant

    @chekerlamer

    Hi,

    I need some help here. I have been searching on Documentation and Forums but nothing related to this. For now, I replace the template location to my plugin with this function bp_register_template_stack to bp_init hooks. So, when my site change to another theme it will not affect the template. I want to apply custom cover image to my template but it makes me confuse because there is no bp-parent-css on my site.

    When i search i got some code that can create a custom cover image but the code is not work for me:

    function cover_image_css( $settings = array() ) {
      /**
      * If you are using a child theme, use bp-child-css
      * as the theme handle
      */
      $settings['theme_handle'] = 'bp-parent-css';
      // Adjust size
      $settings['height'] = 300;
    
      $settings['callback'] = 'cover_image_callback';
    
      return $settings;
    }
    
    function cover_image_callback( $params = array() ) {
      if ( empty( $params ) ) {
        return;
      }
    
      return '#buddypress #header-cover-image {
      height: ' . $params['height'] . 'px;
      background-image: url(' . esc_url( $params['cover_image'] ) . ');
      }';
    }
    add_filter( 'bp_before_xprofile_cover_image_settings_parse_args', 'cover_image_css', 10, 1 );
    add_filter( 'bp_before_groups_cover_image_settings_parse_args', 'cover_image_css', 10, 1 );
    

    I am not really experienced with BuddyPress so I would really appreciate some help.

    Thank you

  • You must be logged in to reply to this topic.
Skip to toolbar