• Resolved jcarignan

    (@jcarignan)


    Hello!

    Thank you for a great plugin that works very well!
    I just updated to the last version and noticed that new WordPress Users are created everytime a payment from a new email is completed. Is there an easy ways to prevent that?

    I don’t ask my customers to enter any infos besides the required email address so I don’t see the need to save the StripeID. I’m totally fine with generating a new StripeID in the case of a another purchase made from the same email address.

    During my testing, I had Stripe.charges errors when I tried to make a purchase in TEST mode after making a purchase in LIVE mode with the same email address. Not 100% sure but I think the reason for this is we cannot have the same stripeID for LIVE and TEST modes. Since the plugin saves the stripeID after a successful purchase, that email can only be used for one mode.

    Cheers!
    Julien

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Nicolas Figueira

    (@nahuelmahe)

    Hello @jcarignan,

    Direct Stripe version 2.0.5 removed the storage of Stripe ID during test mode transaction to prevent this common error users were getting. This error shouldn’t happen anymore if you keep experiencing it please let me know!

    Otherwise if you do not want to store Direct Stripe user at all, I made a gist you can add to your (child-)theme functions.php file, that will delete the previously created user… And not delete the user if he/she is a logged in (known) user.

    Find it at https://newo.me/direct-stripe-delete-user-after-each-transaction-to-stop-storing-them/
    Or
    https://gist.github.com/New0/8b35ab759a7b72b0ca72af3bee790973

    I hope that will help.

    Best regards

    Thread Starter jcarignan

    (@jcarignan)

    Hello Nicolas and sorry about the late reply!

    Yes, that was I ended up doing, deleting the freshly-created user on a successful transaction callback.

    I would edit the code on your website + gist though, because if we are logged out but use the email of the main Administrator wordpress user, it will completely destroy the WP database! wp_delete_user deletes ALL the content associated with the user if we don’t use the second param!

    I still think there should be an option to completely bypass creating new WordPress Users when we don’t need to track purchases made with the same email address.

    This is what I use:

    
    function on_stripe_payment_completed($chargeID, $post_id, $button_id, $user_id) {
        if (!user_can($user_id, 'administrator') && user_can($user_id, 'stripe-user')) {
                $admin_user_id = get_users(array(
                    'role' => 'administrator',
                    'number' => 1,
                    'orderby' => 'ID'
                ))[0]->ID;
            wp_delete_user($user_id, $admin_user_id);
        }
    }
    

    Thanks!
    Julien

    • This reply was modified 7 years, 3 months ago by jcarignan.
    • This reply was modified 7 years, 3 months ago by jcarignan.
    • This reply was modified 7 years, 3 months ago by jcarignan.
    Plugin Author Nicolas Figueira

    (@nahuelmahe)

    Hello @jcarignan,

    Thank you about that! The precipitation without a real study case was a bad combination ! I will edit the code ASAP.

    Best regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Prevent creating new WP users on success’ is closed to new replies.