Title: BuddyPressプロフィールページ（マイページ）のURLを/members/user_idへ変更
Last modified: 2016年7月30日

---

# BuddyPressプロフィールページ（マイページ）のURLを/members/user_idへ変更

 *  [mteshy](https://ja.wordpress.org/support/users/mteshy/)
 * (@mteshy)
 * [13年、 4ヶ月前](https://ja.wordpress.org/support/topic/buddypress%e3%83%97%e3%83%ad%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%9a%e3%83%bc%e3%82%b8%ef%bc%88%e3%83%9e%e3%82%a4%e3%83%9a%e3%83%bc%e3%82%b8%ef%bc%89%e3%81%aeurl%e3%82%92membersuser_id%e3%81%b8/)
 * 現在、BuddyPressを利用し会員制サイトを制作しております。
 * ユーザーのプロフィールページ（マイページ）はBuddyPressの基本構造では
    /members/
   usernameになっておりますが、/members/user_idの構成にしたいと考えております。
 * そこで、いろいろネットを調べましたところ、同じ質問をされている方がおりました。
 * [http://buddypress.org/support/topic/member-profile-url-with-user-id-instead-of-username/#post-165054（英語サイト）](http://buddypress.org/support/topic/member-profile-url-with-user-id-instead-of-username/#post-165054（英語サイト）)
   
   その中でフックを公開されている方がおりまして、https://gist.github.com/dzmounir/
   5503865
 * ——————————————————————-
    上記サイトより引用
 *  <?php
 * function bp_get_user_domain_with_id( $domain, $user_id, $user_nicename = false,
   $user_login = false ) {
 *  if ( empty( $user_id ) )
    return;
 *  if( isset($user_nicename) )
    $user_nicename = bp_core_get_username($user_id);
 *  //if ( !$domain = wp_cache_get( ‘bp_user_domain_’ . $user_id, ‘bp’ ) ) {
    $after_domain
   = bp_get_members_root_slug() . ‘/’ . $user_id;
 *  $domain = trailingslashit( bp_get_root_domain() . ‘/’ . $after_domain );
    $domain
   = apply_filters( ‘bp_core_get_user_domain_pre_cache’, $domain, $user_id, $user_nicename,
   $user_login );
 *  // Cache the link
    if ( !empty( $domain ) ) { wp_cache_set( ‘bp_user_domain_’.
   $user_id, $domain, ‘bp’ ); } //}
 *  return $domain;
 * }
    add_filter(‘bp_core_get_user_domain’, ‘bp_get_user_domain_with_id’, 10, 4);
 * // Warning部分
    function bp_get_userid_with_id($userid, $username){ //if the 
   username is an userid ? if(ctype_digit($username)){ // check if a user with userid
   equal to $username exist $aux = get_userdata( $username ); if( get_userdata( 
   $username ) ) $userid = $username; } return $userid; } add_filter(‘bp_core_get_userid’,‘
   bp_get_userid_with_id’, 10, 2); ——————————————–ここまで
 * //add_filter(‘bp_core_get_userid_from_nicename’, ‘bp_get_userid_with_ideddde’,
   10, 1);
 * // bp_core_get_userid_from_nicename filter havn’t the $username in param 🙁 so
   i was
    // add filter to bp_is_username_compatibility_mode to force the excution
   of bp_core_get_userid // *** check line 261 of bp-core-catchuri.php ***
 * function bp_is_username_compatibility_mode_always_true(){
    return true; } add_filter(‘
   bp_is_username_compatibility_mode’, ‘bp_is_username_compatibility_mode_always_true’);
 * ?>
    ——————————————————————
 * テストサイトにてfunctions.phpに記述してみましたが、確かにプロフィールページが/
   members/user_idになるのですが、
    プロフィール自体が表示されない現象に陥っており
   ます。
 * なおこのコードを実行しますとWarning: Missing argument 2 for bp_get_userid_with_id()
   in /wp-content/themes/my-theme/functions.php on line 117
    のメッセージが出力さ
   れます。
 * BuddyPressのコアのソースを解析しておりますが、いかせん、hockについての知識が少ない
   ため
    四苦八苦しております。
 * お手数をおかけしますが、どなたかご教示頂けないでしょうか？
 * 宜しくお願いします。
 * wordpress ver 3.5.1
    BuddyPress ver 1.6.4

 トピック「BuddyPressプロフィールページ（マイページ）のURLを/members/user_idへ変更」
には新たに返信することはできません。

## タグ

 * [BuddyPress](https://ja.wordpress.org/support/topic-tag/buddypress/)

 * フォーラム: [プラグイン](https://ja.wordpress.org/support/forum/plugins/)
 * 0件の返信
 * 1人の参加者
 * 最後の返信者: [mteshy](https://ja.wordpress.org/support/users/mteshy/)
 * 最後の活動: [13年、 4ヶ月前](https://ja.wordpress.org/support/topic/buddypress%e3%83%97%e3%83%ad%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%9a%e3%83%bc%e3%82%b8%ef%bc%88%e3%83%9e%e3%82%a4%e3%83%9a%e3%83%bc%e3%82%b8%ef%bc%89%e3%81%aeurl%e3%82%92membersuser_id%e3%81%b8/)
 * 状態: 未解決

## トピック

### 人気のトピック

### 返信がないトピック

### サポート関連ではないトピック

### 解決済みのトピック

### 未解決のトピック

### すべてのトピック
