WordPress.org

Ready to get started?Download WordPress

Forums

PayPal Donations
Donote button to open a new tab with Paypal (6 posts)

  1. raamklaza
    Member
    Posted 3 years ago #

    Hi,

    I like your plugin it's really usefull.

    I have a few customization questions and i hope you can help me.

    When people click the donate button i would like to see that paypal would open in a new page, how can i do this? I searched through the code but i can't find a <a href or something.

    Is it possible to add the username (if logged in) to the reference? I tried in the admin with <?php get_username() ?> but it will just put "<?php get_username() ?>" in the paypal page and not the real username.

    http://wordpress.org/extend/plugins/paypal-donations/

  2. Johan Steen
    Member
    Plugin Author

    Posted 3 years ago #

    If you don't mind making some modifications to the code, you can fix the new page pretty easy by adding a target="_blank" to the form tag.

    Locate the form tag in the code (around line 152 in v1.4.9.4):
    $paypal_btn .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">';
    and change it to:
    $paypal_btn .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">';

    You could also modify the $reference part in the same function (generate_html()) to use the get username function istead.
    Change:
    $reference = (!$reference) ? $pd_options['reference'] : $reference;
    to:
    $reference = get_username();

    You could probably even though something like:

    if(is_user_logged_in())
    	$reference = get_username();

    Hope this helps some.

    Cheers,
    Johan

  3. raamklaza
    Member
    Posted 3 years ago #

    Sweet! I will do that, thank you very much.

  4. raamklaza
    Member
    Posted 3 years ago #

    When i do the following:

    Change:
    $reference = (!$reference) ? $pd_options['reference'] : $reference;
    to:
    $reference = get_username();

    The donate button disappears from the website.

    It will look like this:
    https://docs.google.com/leaf?id=0B5jM3_QoawD6ZWVjMjZjY2UtZWIxNS00N2MwLWE0MjQtNTAxZjY4OGJkOWYx&hl=en_US&authkey=CKnZurkO

    Originally with out the change it looks like this:
    https://docs.google.com/leaf?id=0B5jM3_QoawD6MDllMjJhYmYtODhkYy00ZGE2LWE1NDYtY2I1OGNlMmM0ZmUy&hl=en_US&authkey=CJX82-QD

  5. Johan Steen
    Member
    Plugin Author

    Posted 3 years ago #

    I'd guess the button disappears because get_username() is a function that doesn't exist, so it throws an error. I assumed that get_username() was some custom function you had.

    Instead you can use WP's own function to get the current username, get_currentuserinfo.

    So then it would look like this:

    global $current_user;
    get_currentuserinfo();
    $reference = $current_user->user_login;

    Cheers,
    Johan

  6. raamklaza
    Member
    Posted 3 years ago #

    Thnx again for your swift reply.

    I used the global like you said and i made this:

    `// Get username from loged in user and post as reference to paypal
    global $current_user;
    get_currentuserinfo();
    if(is_user_logged_in())
    {
    $reference = $current_user->user_login;
    }
    else
    {
    $reference = 'Donatie van gastbezoeker'; // Donation from not logged in visitor
    }`

    Works like a charm.

    Thnx for your help.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic