Guest User

Untitled

a guest
Oct 5th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. // Register the Cover Image feature for Users profiles
  2. function bp_default_register_feature() {
  3. /**
  4. * You can choose to register it for Members and / or Groups by including (or not)
  5. * the corresponding components in your feature's settings. In this example, we
  6. * chose to register it for both components.
  7. */
  8. $components = array( 'groups', 'xprofile');
  9.  
  10. // Define the feature's settings
  11. $cover_image_settings = array(
  12. 'name' => 'cover_image', // feature name
  13. 'settings' => array(
  14. 'components' => $components,
  15. 'width' => 1600,
  16. 'height' => 800,
  17. 'callback' => 'bp_default_cover_image',
  18. 'theme_handle' => 'bp-default-main',
  19. ),
  20. );
  21.  
  22.  
  23. // Register the feature for your theme according to the defined settings.
  24. bp_set_theme_compat_feature( bp_get_theme_compat_id(), $cover_image_settings );
  25. }
  26. add_action( 'bp_after_setup_theme', 'bp_default_register_feature' );
  27.  
  28.  
  29. function bp_cover_img_path() {
  30. // Is the current page a user page?
  31. if ( bp_is_user() ) {
  32.  
  33. $user_id = bp_displayed_user_id();
  34.  
  35. $attachment = bp_attachments_get_attachment( 'url', array( 'item_id' => $user_id ) );
  36.  
  37. $image_path = $attachment;
  38. // output only if an attachment exist
  39. if( !empty( $attachment ) ):
  40. echo $image_path;
  41. endif;
  42.  
  43. }
  44. }
  45. add_action( 'bp_profile_cover_path', 'bp_cover_img_path' );
Advertisement
Add Comment
Please, Sign In to add comment