Fix for failed add/renew products on a integrated Wordpress / Amember installation

Discussion in 'Integration' started by andyb, Nov 4, 2010.

  1. andyb

    andyb Member

    Joined:
    Jul 10, 2010
    Messages:
    41
    I have found a small issue when amember is fully integrated with Wordpress by using the methods found here and here

    When a user tries to add a new product or renew one after they are already a member, it will fail with an empty error because of the different way Wordpress and Amember treat a global $error var


    in /amember/member.php function do_renew() there is a global declaration of $error

    in a standard install of amember, the global of error results in NULL so when checks are made by validate_member_form it returns an array with no values.

    in a wordpress integrated amember, the global of $error results in an empty array value
    array([0] = '') which is treated as a value so in the do_renew() function where it has this
    PHP:
    if (count($error)){
       
    $t->assign('error'$error);
    return;
    }
    the count($error) will result in a positive which makes the $t->assign fire.

    this prevents the product from being renewed and shows an empty error instead.

    I have changed the code in do_renew() to

    PHP:
    if (count($error)){
       if(
    $error[0] != '') {
          
    $t->assign('error'$error);
          return;
       }
    }
    This allows the add/renew product to go through ok and should (I am sure) still be ok if an error happens.

    There are two other places in amember where count($error) is used to determine if an error happened or not. In signup.php and aff_signup.php . They don't cause problems to me because my validate_signup_form function passes back $error = array(); with no values set if no errors have happened which is compatible with the way Amember does things.

    I have submitted a support ticket but thought I'd put it here for the (very) few people who are doing their own integration of amember and wordpress.

    if you are, check your add/renew product function to make sure it works.

    Alex, can you check this and perhaps add it to the next version if it is compatible with the rest of the error checking in amember?
  2. kengary

    kengary aMember Pro Customer

    Joined:
    Nov 13, 2008
    Messages:
    231
    Hey Andy!

    Great information. I got stuck on this doing Authorize.NET processing. It cannot complete payments because of the way Wordpress does its magic quotes. The payment information doesn't get passed to the Authorize plugin properly. I showed it to the aMember support desk and we didn't come up with a solution.

    Do you use Authorize with this method or always PayPal, ClickBank or 1SC...a payment that takes place off of your server so it doesn't matter?

    Ken
  3. andyb

    andyb Member

    Joined:
    Jul 10, 2010
    Messages:
    41
    we actually haven't taken any payments on this system yet, it's been a mammoth task getting everything else ready so we haven't launched yet.

    we will be using only paypal.

    I'll have a play with my local install to see if I can get authorize payments configured..
    [edit] turns out authorize net charge a setup fee so I wont be able to test it. sorry.
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Andy,
    thanks for the suggestion. Will add fix to next release.

Share This Page