Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!

bp-custom.php

By: danfolt on Jul 4th, 2013  |  syntax: PHP  |  size: 2.17 KB  |  views: 100  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. function inspired_record_more_types( $types ) {
  3.  
  4.     $types[] = 'portfolios';
  5.     $types[] = 'applicants';
  6.  
  7.     return $types;
  8. }
  9.  
  10. add_filter( 'bp_blogs_record_post_post_types', 'inspired_record_more_types', 1, 1);
  11.  
  12. // This function should go in functions.php
  13. function mam_posts_where ($where) {
  14.    global $mam_global_where;
  15.    if ($mam_global_where) $where .= " $mam_global_where";
  16.    return $where;
  17. }
  18. add_filter('posts_where','mam_posts_where');
  19.  
  20. // Get user role
  21. function get_role($user_id)
  22. {
  23.     if(is_int($user_id))
  24.     {
  25.         $user = new WP_User( $user_id );
  26.         if ( !empty( $user->roles ) && is_array( $user->roles ) )
  27.         {
  28.             foreach ( $user->roles as $role )
  29.                 echo $role;
  30.         }
  31.     }
  32.     else
  33.         echo "Something else";
  34. }
  35.  
  36.  
  37. // Dynamically Populating the Post Author
  38.  add_filter('gform_field_value_author_email', 'populate_post_author_email');
  39. function populate_post_author_email($value){
  40.     global $post;
  41.  
  42.     $author_email = get_the_author_meta('email', $post->post_author);
  43.  
  44.     return $author_email;
  45. }
  46.  
  47. // BuddyBlog
  48. add_filter('buddyblog_get_post_type','buddyblog_my_post_type');
  49.  
  50. function buddyblog_my_post_type($post_type){
  51.  
  52. return 'portfolio';// it can be say 'events' or 'movies' or anything, just make sure you have already registered the post type
  53.  
  54. }
  55. add_filter('buddyblog_get_post_type','buddyblog_my_post_type');
  56.  
  57. function buddyblog_my_post_type($post_type){
  58.  
  59. return 'post';// it can be say 'events' or 'movies' or anything, just make sure you have already registered the post type
  60.  
  61. }
  62.  
  63. <?php
  64.       function shorten_text($text, $length) {
  65.           $shortened_text = substr($text, 0, $length);
  66.           $shortened_text .= '…';
  67.           return $shortened_text;
  68.       }
  69.       if (have_posts()) : while (have_posts()) : the_post();
  70.           $title=the_title('','',FALSE);
  71.           $shortened_title = shorten_text($title, 15);
  72.           print $shortened_title;
  73.       ?>
  74.           <?php endwhile;?>
  75.         <?php else : ?>
  76.           <h2>Introuvable</h2>
  77.           <p>Désolé, mais vous cherchez quelque chose qui n'est pas ici.</p>
  78.       <?php endif; ?>
  79.      
  80. ?>