• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Tips and Tricks HQ

  • Home
  • Blog
  • Projects
    • All Projects
    • Simple WP Shopping Cart
    • WP Security and Firewall Plugin
    • WP Download Monitor
    • WP eStore Plugin
    • WP Affiliate Platform
    • WP eMember
    • WP PDF Stamper
    • WP Lightbox Ultimate
    • WP Photo Seller
  • Products
    • All Products
    • Checkout
  • Support
    • Support Portal
    • Customer Only Forum
    • WP eStore Documentation
    • WP Affiliate Software Documentation
    • WP eMember Documentation
  • Contact

Create PayPal Payment Button for The Post Author Automatically

You are here: Home / Web Development / Create PayPal Payment Button for The Post Author Automatically

Last updated: June 13, 2014 by Ruhul Amin





I received the following question from a user today:

When users create a charity on my site, I want to have a donate button on their post that automatically gets the proper email address to use for the PayPal transaction. This way I don’t have to manually add their email to the shortcode for every charity that is created on my site.

This is a quick tutorial for users who want to create a PayPal payment button widget in the blog posts using the author’s PayPal email address. This way the payment or donation directly goes to the post author’s PayPal account. Here is how to do it:

Step 1

Grab the free WP PayPal Payment Plugin and install it (if you don’t have it installed already). This plugin lets you crate payment widgets to accept PayPal payment.



Step 2

Open your theme’s functions.php file and add the following snippet of code:

add_filter('wppp_widget_email', 'custom_payment_widget_email');
function custom_payment_widget_email($email){
$email = get_the_author_meta('user_email');
return $email;
}

add_filter('wppp_widget_any_amt_email', 'custom_payment_any_amt_widget_email');
function custom_payment_any_amt_widget_email($email){
$email = get_the_author_meta('user_email');
return $email;
}

The above code will override the PayPal email address value of the payment widget with the post author’s email address automatically.

Step 3

Now, you can use the shortcodes offered by the PayPal payment widget plugin to place a payment widget anywhere inside the WordPress post or you can add the widget from your theme’s template file.

Below is an example of what you could add in your theme’s template file to create the payment widget (the “email” parameter will be auto populated when the page renders):

<?php echo do_shortcode('[wp_paypal_payment_box email="" options="Payment 1:15.50|Payment 2:30.00|Payment 3:50.00"]'); ?>

Note: You can also add custom author meta to store the user’s PayPal email address then modify the code in step 2 to use that value (instead of the default email address value).

Related Posts

  • WP Donations Plugin – Create a Donation Widget with Donation Goal
  • WordPress Easy Paypal Payment or Donation Accept Plugin
  • WordPress Simple Paypal Donation Plugin
  • How to Install WordPress Multi-Site in Localhost (Using XAMPP)

Web Development,  Wordpress accept paypal payment,  Paypal,  paypal donation,  wordpress paypal

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Featured & Popular Articles

Video Answers to Top WordPress QuestionsWordPress Optimization Tips and Tricks for Better Performance and SpeedEssential WordPress Security Tips - Is Your Blog Protected?WordPress Simple PayPal Shopping Cart PluginTop 15 Search Engine Optimization (SEO) Techniques I Forget to DoList of the Best and Must Use WordPress PluginsHow do I Start a Blog and Make Money Online?Good Domain Name Picking Tips for Your Blog SetupFind Out Which WordPress Web Hosting Company Offers the Cheapest and Reliable Web Hosting Solution

Featured WordPress Plugins

wordpress estore plugin
wordpress membership plugin
WordPress PDF Stamper Plugin
WordPress Lightbox Ultimate Plugin
WordPress photo seller plugin
wordpress affiliate plugin

Recent Posts

  • PayPal's Pay in 4 Feature [...]
  • Add a WordPress Admin User Account via PHP [...]
  • Enabling Two-Factor Authentication (2FA) for a PayPal Acco [...]
  • PayPal Test Cards (Sandbox Testing) [...]
  • How to Make a Stripe Text Link Payment Button [...]

Comment & Socialize

  • Thank you very much! ...
    - Nataliya
  • Thank you for quickly answe ...
    - Alain
  • @Robin, Looks like the pric ...
    - admin
  • @Dave, Try the following in ...
    - admin
  • Hi, A customer paid but ord ...
    - Robin

Check out our solutions

View our WordPress plugin collection and start using them on your site.

Our WordPress Solutions

Footer

Company

  • About
  • Privacy Policy
  • Terms and Conditions
  • Affiliate Program
  • Affiliate Login

Top WordPress Plugins

  • Simple Shopping Cart
  • PayPal Donations
  • All in One WP Security
  • WP eStore
  • WP eMember

Blogging Tips

  • How to Start a Blog
  • Selecting a Good Domain
  • Cheap WP Hosting
  • WP Video Tutorials
  • Simple SEO Tips

Search


Keep In Touch

Copyright © 2021 | Tips and Tricks HQ