Wordpress Plugin Developer Question

6 replies
I'm working on my first plugin.

It accomplishes three tasks.

1. It submits a post to my blog.
2. It submits the users email to an autoresponder.
3. It collects money thru paypal.

I'm using a paypal class I found to do the paypal work and I've integrated the autorespond and post submit taskse into the processing that's done to submit to Paypal.

I'm doing this on a PHP page that I've loaded the wordpress codex onto.

So here is my issue.

Initially I had the developer credentials for Paypal in a config file. Rather than the blog owner being forced to enter their credentials in a config file however, I added an admin screen that allows the blog owner to store the credentials in the Wordpress DB.

The problem is that when I attempt to use the get_option function in my paypal process I'm not getting my data back so the paypal piece breaks.

I believe the issue is that when my papal call returns, the page doing the paypal work is reloaded and the get_option function is not available so that the call to get_option fails.

Honestly, I'm pretty stumped.

So my hope is two-fold. One, obviously I'd like to resolve this issue.

More importantly I'm trying to understand the "right" way to perform these tasks while integrating into the wordpress framework.

I'm sure I'm going about this the wrong way which is causing my issue.

Where did you learn the "right" way to integrate functionality into these plugins.

Thanks in advance for any assistance you can offer.
#developer #plugin #question #wordpress
  • Profile picture of the author Nathan K
    Are you trying to output the values if so did you use 'echo' before get_option(), this is something i always forget to enter.
    {{ DiscussionBoard.errors[8552105].message }}
  • Profile picture of the author SteveJohnson
    There is no 'right' way.

    The most efficient way, if you don't really need access to all of WordPress's functionality in your postback processor, is to manually hook up to the database and retrieve the needed information from the -options table.

    Another way is to create a 'listener' as a plugin that intercepts the POST values and processes them if they come from PayPal.

    Lots of ways to skin this cat, none are particularly simple.
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[8554976].message }}
  • Nathan and Steve

    Thanks for your responses. I had been watching this thread but had seen no responses so I thought sure it had fallen off by now. I came back to check and wanted to say thanks.

    Nathan, thanks for the idea, the echo thing is not my issue.

    Steve

    Thanks for the feedback. Since I posted I ripped apart my paypal piece of the process thanks to paypal changing it up on their side and my code suddenly breaking. As I'm sure you have experienced, it only made it/me stronger. ;-)

    Have a great day.

    Thanks
    {{ DiscussionBoard.errors[8565875].message }}
  • Profile picture of the author kpmedia
    This isn't really "WordPress" as much as it's PHP.
    {{ DiscussionBoard.errors[8567574].message }}
    • Originally Posted by kpmedia View Post

      This isn't really "WordPress" as much as it's PHP.
      Actually the issue is wordpress. My troubles are when I need to do get_option to grab my paypal credentials.

      Then I need to grab get_option to grab other credentials when I return from paypal.

      My hope was that session variables would hold the values between trips to no avail.

      I reworked the page in hopes of resolving this challenge. I did this midweek last week and have not been back to it again since. I'm hoping to get some time in on it tonight.

      Thanks again.
      {{ DiscussionBoard.errors[8570567].message }}
  • Profile picture of the author sorinnunca
    There are 2 ways to do this as SteveJohnson said:

    - Have your ipn script as a simple php file, connect to the database with php and update what you want.

    - Create a listener as a WP Plugin. 1 way to do this (that would work for sites with permalinks off to) is to hook into the template_redirect hook.

    Make up your url as: http://site.com/?do=ipn
    That would be your ipn url;
    Then inside the plugin hook into the template_redirect hook and do something like
    if($_GET['do']=='ipn')
    // pp code here
    die(); // to make sure the rest of the page isn't rendered.
    {{ DiscussionBoard.errors[8570589].message }}

Trending Topics