2012-05-04 58 views
1

我使用Wordpress模板作为一个系统来收集口头报价,真的发表评论,这将花费访问者到该网站$ 1作出。我已将帖子末尾的标准“发表评论”文字更改为“提交出价”。链接贝宝“捐赠”按钮Wordpress“发表评论”按钮

我还安装了一个PayPal捐赠插件,在页面上显示“捐赠”按钮。

我想将这两个按钮的功能合并到一个按钮中,“提交出价”按钮。要明确,提交出价按钮将用户的评论发布到帖子页面;我需要一个按钮来执行此操作,同时指导用户使用PayPal捐赠$ 1。

理想情况下,我需要一个支票来验证用户是否实际支付了1美元才能提交出价,但由于这更复杂,并且因为这是为了慈善目的,所以我正在将相信我的用户真正付费。捐赠后,PayPal会将其重定向到他们提交口头投标的页面(“评论”)。

为“提交投标”按钮PHP的样子(这是从标准的“典型的WordPress博客中的comments.php):

<input type="submit" value="Submit Bid" /><input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /> 

贝宝‘捐赠’按钮,实际上是放在一个插件该页面的函数:

<?php echo Paypal_payment_accept(); ?> 

功能码是相当长的,但将实际的代码“捐赠”页面上的按钮:

$output .= "<input type=\"image\" src=\"$payment_button\" name=\"submit\" alt=\"Make payments with payPal - it's fast, free and secure!\" />"; 

非常感谢关于如何解决这个看似微不足道的问题的想法!

回答

1

其实,可能有一种更简单的方法,而不是使用PayPal提交使用表单。

保持重定向代码,但编辑$位置变量是将用户带到贝宝,所有要发送给他们的变量的URL, 如: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=email%40paypalhacks%2Ecom&amount=1%2E00&currency_code=USD&item_name=donation&item_number=1001&quantity=1&shipping=3%2E00&no_shipping=0

所以它会处理正常评论,然后将用户发送到PayPal页面进行付款。您可以在浏览器中转到该网址以检查它是否有效。可能还会添加一个'返回'变量以将用户发回原始$位置值,以便用户在成功付款至贝宝后即可访问评论页面。

+0

认为这应该做的。谢谢! – keypulsations

0

你基本上想要一个按钮,执行2个动作。因此,为了不使用两种形式(paypal插件会添加自己的表单标签),为什么不在注释处理代码之前或之后添加paypal重定向功能?

因此,当用户按下评论上的提交按钮时,让页面正常处理提交,但是在该文件中,在处理评论之后,将用户重定向到paypal。

您可以更改wp-comments-post.php文件中的代码,该文件位于您的根Wordpress文件夹中。

你不需要使用这个插件,它的一个非常简单的PayPal代码:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> 
<input type="hidden" name="cmd" value="_xclick"> 
<input type="hidden" name="business" value="<!-- paypal user email which receives payments -->"> 
<input type="hidden" name="lc" value="CA"> 
<input type="hidden" name="item_name" value="<!-- donation -->"> 
<input type="hidden" name="item_number" value="1"> 
<input type="hidden" name="amount" value="<!-- donation amount -->"> 
<input type="hidden" name="currency_code" value="CAD"> 
<input type="hidden" name="return" value="<!-- the URL to redirect the user after payment -->"> 
<input type="hidden" name="button_subtype" value="services"> 
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted"> 
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> 
       <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"><br /> 
      </form> 

此外,您可以适度的所有意见,所以直到批准由一个主持人,他们没有在网站上公布。您可以在信息中心>设置>讨论中管理这些设置。这样,您可以选择仅批准通过PayPal(通过比较其电子邮件ID)成功进行付款的用户的评论。

+0

感谢您的好建议。我无法准确找到wp-comments-post.php文件中放置PayPal代码的位置。我相信它应该与以下内容交互:​​$ comment_post_ID = isset($ _ POST ['comment_post_ID'])? (int)$ _POST ['comment_post_ID']:0; – keypulsations

+0

另一件事:我想我应该删除wp-comments-post.php文件底部的重定向代码? $ location = empty($ _ POST ['redirect_to'])? get_comment_link($ comment_id):$ _POST ['redirect_to']。 '#comment-'。 $ COMMENT_ID; $ location = apply_filters('comment_post_redirect',$ location,$ comment); wp_safe_redirect($ location); – keypulsations

+0

看到回答下面发布 – anuragbh