2011-07-27 11 views
4

機能「メッセージを送信するには、」ボタンのPHPファイルにここに挿入「友達を追加」リンクをボタンに切り替えるにはどうすればよいですか?それは、例えば、 「プライベートメッセージを送る」リンク

<div><a href="<?php bp_send_private_message_link() ?>" class="myButton"></a></div> 

として動作します。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
    <title>IS THIS THING ON?</title> 
    <link rel="stylesheet" href="./wp-content/themes/cosmicbuddy/_inc/css/screen.css" type="text/css" /> 
</style> 
</head> 
<body> 
    <div> 
     <a href="<?php bp_send_private_message_link() ?>" class="myButton"></a> 
    </div> 
    <div> 
     <a href="<?php bp_send_public_message_link() ?>" class="myButton"></a> 
    </div> 
</body> 
</html> 

が、私はそれを獲得したタグの間にこれを挿入したとき仕事はありません。それはちょうど私がソースを見つけることを試みたが、私はOBV思ったよりもそれに多くのがありますテキストは「友情のキャンセル」

<?php if (function_exists('bp_add_friend_button')) : ?> 
    <?php bp_add_friend_button() ?> 
<?php endif; ?> 

を示しています。最初はボタンが「友達を追加」であるため、ユーザーがあなたの友人であれば、「友人関係をキャンセルする」と表示されます。

アイデア?

友人の追加/キャンセルリンクの背後にあるコードは、それが解決に役立つ可能性がある場合はそれを探すことができますか?宣言があるとして、あなたは、関数に友人のIDを提供する必要がありますように

+3

"" あなたの機能が動作し1.howこのaswell :) – benhowdle89

+0

の下にPHPに適用されますか? (ここにテーマを貼り付けることはできますか?) 2.私はあなたがあなたの関数で 'echo'や 'print'をすると思いますが、' function() 'でリターンし、このような関数を呼び出すことをお勧めします' <?php echo foo(); ?> ' – ncm

+0

と私はあなたが意味することを理解できません "作品ではなく、単にテキストを表示します"。私はその点が彼らの位置にないあなたの機能にあると思う。 – ncm

答えて

0

はルックス:

function bp_add_friend_button($potential_friend_id = 0, $friend_status = false) 

そうでない場合は、IDが別の関数で取得されています

function bp_get_potential_friend_id($user_id = 0) { 
    global $friends_template; 

    if (empty($user_id) && isset($friends_template->friendship->friend)) 
     $user_id = $friends_template->friendship->friend->id; 
    else if (empty($user_id) && !isset($friends_template->friendship->friend)) 
     $user_id = bp_displayed_user_id(); 
    return apply_filters('bp_get_potential_friend_id', (int) $user_id); 
} 

あなたが調べることができますBuddyPressの機能はここにあります:http://phpxref.ftwr.co.uk/buddypress/nav.html?_functions/index.html希望します。

0

友達のリクエストを表示し、リンクを拒否したいと思うと思います。

コードの下に試してみてください:

<div><a href="<?php echo bp_get_friend_accept_request_link() ?>" class="myButton">Friends Accept</a></div> 

<div><a href="<?php echo bp_get_friend_reject_request_link() ?>" class="myButton">Friends Reject</a></div> 
関連する問題