4

“发送私人消息”功能用作按钮

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

在此处插入 PHP 文件时:

<!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>

但是当我在标签之间插入它时它不起作用。它只显示文字“取消友谊”

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

我试图找到来源,但它比我想象的要多得多。因为一开始按钮是“加好友”,如果用户是你的好友,就会显示“取消好友”。

有任何想法吗?

如果这可能有助于解决它,我可以查找添加/取消友谊链接背后的代码?!

4

2 回答 2

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>
于 2013-11-14T07:35:00.347 回答
0

看起来您需要向函数提供朋友 ID,因为声明是:

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希望对您有所帮助。

于 2013-06-12T13:47:35.370 回答