Guest User

Url change

a guest
Oct 14th, 2014
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function _bp_core_get_user_domain($domain, $user_id, $user_nicename = false, $user_login = false) {
  2. if ( empty( $user_id ) ){
  3. return;
  4. }
  5. if( isset($user_nicename) ){
  6. $user_nicename = bp_core_get_username($user_id);
  7. }
  8. $after_domain = bp_get_members_root_slug() . '/' . $user_id;
  9.  
  10. $domain = trailingslashit( bp_get_root_domain() . '/' . $after_domain );
  11. $domain = apply_filters( 'bp_core_get_user_domain_pre_cache', $domain, $user_id, $user_nicename, $user_login );
  12. if ( !empty( $domain ) ) {
  13. wp_cache_set( 'bp_user_domain_' . $user_id, $domain, 'bp' );
  14. }
  15. return $domain;
  16. }
  17.  
  18. add_filter('bp_core_get_user_domain', '_bp_core_get_user_domain', 10, 4);
  19.  
  20. function _bp_core_get_userid($userid, $username){
  21. if(is_numeric($username)){
  22. $aux = get_userdata( $username );
  23. if( get_userdata( $username ) )
  24. $userid = $username;
  25. }
  26. return $userid;
  27. }
  28.  
  29. add_filter('bp_core_get_userid', '_bp_core_get_userid', 10, 2);
  30.  
  31. function _bp_get_activity_parent_content($content){
  32. global $bp;
  33. $user = get_user_by('slug', $bp->displayed_user->fullname); // 'slug' - user_nicename
  34. return preg_replace('/href=\"(.*?)\"/is', 'href="'.bp_core_get_user_domain($user->ID, $bp->displayed_user->fullname).'"', $content);
  35. }
  36.  
  37. add_filter( 'bp_get_activity_parent_content','_bp_get_activity_parent_content', 10, 1 );
  38.  
  39. add_filter('bp_core_get_userid_from_nicename', '_bp_core_get_userid', 10, 2);
RAW Paste Data