Pings on membership

Hello
I don't understand what the edit pings is about. Can someone explain? How do I set it up and use it?

Dustin

  • DavidM
    • DEV MAN’s Mascot

    Hi Dustin,

    I'll check with the team about getting the Pings mentioned on the project page along with instructions for usage but I'll be glad to cover some of that right here with a quick example as well.

    Membership Pings are an advanced feature meant more for developers, that let you send out "pings" whenever particular actions occur within Membership, such as membership level and subscription movement (ie. when a member's membership level changes).

    So as an example, what we have here is a basic file that that the Ping will communicate with. We'll call it pingtest.php and it can be placed anywhere on the server. Here's the code for it:

    <?php
    $to = 'my@email.com';
    $subject = 'Testing';
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $message = "Blog url: ".$_POST['blogurl']."<br>
    		   Username: ".$_POST['username']."<br>
    		   Subscription: ".$_POST['subscription']."<br>
    		   Membership Level: ".$_POST['level']."<br>
    		   " ;
    mail($to, $subject, $message, $headers);
    ?>

    Creating a blank file, calling it pingtest.php, then pasting that code into it, we can then copy that file into the domain root at domain.com/.

    Now we'll go to Membership > Edit Pings. The Ping could then be setup somewhat as follows:

    Ping Name: Ping Test
    Ping URL: http://domain.com/pingtest.php
    Ping Data:
    blogurl=%blogurl%
    username=%username%
    subscription=%subscriptionname%
    level=%levelname%

    Strip query strings from URL: POST

    With that Ping created, you can now specify that Ping in any of your subscriptions or membership levels and whenever they're added to a member, it will set off the Ping.

    In this particular case, the Ping results in an email being sent to the email specified in the pingtest.php script. That email will include the blog name, username of the member in question, subscription level being added/change, and membership level being added/changed.

    With that, you can easily have Membership automatically send an email to the admin whenever movement occurs in Membership.

    It may be much easier to use a plugin such as Formidable Forms, though I haven't tried the combination as yet.
    http://wordpress.org/extend/plugins/formidable/

    Let me know if you've got any questions on this, will be glad to help. :slight_smile:

    Cheers,
    David

  • DavidM
    • DEV MAN’s Mascot

    Hi Dustin,

    Ultimately, since the Pings really are meant more for developers, the instructions would likely seem much like the instructions I just gave. Fortunately though, these instructions don't involve any actual coding since the code's all provided, it's just a matter of copy-pasting.

    That said, we'll be happy to delve into any individual questions you might have on it all right here in the forums. Just let us know! :slight_smile:

    Thanks,
    David

  • BobWalsh
    • WPMU DEV Initiate

    Hi David - trying to get a ping out of Membership beta 2 . Using your code, I get the email, the email has the labels, but no data. Have tried to ping from level and subscription.

    What am I doing wrong?

    code:

    <?php
    $to = 'bob.walsh@47hats.com';
    $subject = 'PingTest1 - new subscriber';
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $message = "Blog url: ".$_POST['blogurl']."<br>
    		   Username: ".$_POST['username']."<br>
    		   Subscription: ".$_POST['subscription']."<br>
    		   Membership Level: ".$_POST['level']."<br>
    		   " ;
    mail($to, $subject, $message, $headers);
    ?>
  • BobWalsh
    • WPMU DEV Initiate

    David -
    Below is the info, but as you said formidable may be a better solution. Can you explain - briefly - what using "a plugin like Formidable Forms to create a form from the WordPress back-end." is about? I understand forms - I'm a programmer. But what is a backend form, what triggers it and where can I find out more info re this approach?

    Cheers,
    Bob

    Here's the php for pingtest1.php:

    <?php
    $to = 'bob.walsh@47hats.com';
    $subject = 'PingTest1 - new subscriber';
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $message = "Blog url: ".$_POST['blogurl']."<br>
    		   Username: ".$_POST['username']."<br>
    		   Subscription: ".$_POST['subscription']."<br>
    		   Membership Level: ".$_POST['level']."<br>
    		   " ;
    mail($to, $subject, $message, $headers);
    ?>

    the file is at the same level as the wp files and folders.

    the results - whether the ping is from subscription or membership or both is the same: an email with this body:

    Blog url:
    Username:
    Subscription:
    Membership Level:

  • Barry
    • DEV MAN’s Mascot

    Do you have your Ping set to post with a GET or a POST? It should be POST if you are using $_POST in the receiving script.

    Can you change the $_POST parts of that to $_REQUEST just to make sure that the variables are being sent through in one way or another.

  • BobWalsh
    • WPMU DEV Initiate

    David/Berry -

    I'm looking for a way during membership signup to automatically send MailChimp more info - specifically the subscriptiontitle, so I can segment my MC list based on what membership they pick.

    David said: "Also, looking back at this, I think this can actually be much more easily done by adding the code to a page template, or easier yet, using a plugin like Formidable Forms to create a form from the WordPress back-end."

    Great! Have installed formidable (free) on a different site, nice. User can now fill in form and submit,

    But can you point me in some direction/explain what you mean by:
    "create a form from the WordPress back-end." - I don't get it. Does some sort of formidable form get populated from the Membership form? or combining somehow the WPMU and a custom form?

  • Barry
    • DEV MAN’s Mascot

    I'm looking for a way during membership signup to automatically send MailChimp more info - specifically the subscriptiontitle, so I can segment my MC list based on what membership they pick.

    That's what the main idea behind the pings was. It all depends on what the API for the relevant services are, and whether they accept a post of get with the information.

    I've not looked at MailChimp so I'm not sure how signups are handled on it.

  • DavidM
    • DEV MAN’s Mascot

    Hi @Justin,

    After Pings are created, they can be set to occur at the start or end of a subscription, when editing a Subscription Plan.

    I've attached a screenshot showing the options at the bottom of the Subscription Plan.

    In case you haven't seen it yet, you'll find details on the creation of Pings here:
    http://www.youtube.com/watch?v=1vRrWidibBg&list=PLV1BcivFAIdtF4p7CYVfMbVAJ4JQ1Rpe9

    Hope that helps! :slight_smile:

    Cheers,
    David

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.