Ping on Membership- small fix needed

Hi, this thread https://premium.wpmudev.org/forums/topic/pings-on-membership-1#post-243844 has been going on for a couple of weeks and is just sitting there so here is the update on my progress and what still needs to be fixed...

Site set up:
membership plugin site by site install on a multisite set up.

Goal
I am trying to send a message to the subsite admin when a user changes his membership level. I am trying to do this through a joining ping.

I am also trying to send the blog user whose membership level is changed an email message.

VeBailovity gave me this code in chat today, it uses the post method. (noreply@mysite.com is replaced with my site email address)

<?php
//Hook up to Wordpress
require('./wp-load.php');

$current_user = wp_get_current_user();
$admin_email = get_bloginfo('admin_email');
$user_email = $current_user->user_email;

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

The from address works but the super admin, not the blog user or the subsite admin receives the message. I tried this logged in as the blog user and also logged in as the subsite admin. Both times only the super admin gets the message.

How do I send the emails to the relevant subsite admin and blog user?

  • aecnu

    Greetings Atlanta,

    Thank you for this great question and a significant item to bring up.

    I have no idea what the answer is to this undocumented and still being developed feature of the Membership plugin.

    Therefore I will see if I can get the lead developer in here with his invaluable insight into this plugin and feature for his advice/advise for us.

    Though this may take a bit longer then a normal ticket, I will try to get him in here asap.

    Cheers, Joe

  • Atlanta

    Closing this ticket.
    Arnold did a great job of figuring out what was going wrong:slight_smile:
    Here is the solution in case anybody else runs in to the same problem.

    1. In my ping set up under remote pings I incorrectly had the following pasted as ping data:

    %blogname%
    %blogurl%
    %username%
    %usernicename%
    %useremail%
    %userid%
    %networkname%
    %networkurl%
    %subscriptionname%
    %levelname%
    %timestamp%

    It should have been:

    blogname=%blogname%
    blogurl=%blogurl%
    username=%username%
    usernicename=%usernicename%
    useremail=%useremail%
    userid=%userid%
    %networkname%
    networkname=%networkurl%
    subscriptionname=%subscriptionname%
    levelname=%levelname%
    timestamp=%timestamp%

    2. pingtest.php
    this code sends an email to the admin and the user who requested a change in subscription plan. Important to note that the admin email is coming from the settings page, not the user profile page. My site has registration disabled so it kind of wrecks havoc on changing the email address in settings, so I don't get the email confirmation messages (that will be a different ticket) so I have to change the email address through the database http://www.doitwithwp.com/reset-wordpress-admin-password/ (temporary solution)

    <?php
    //Hook up to Wordpress
    require('./wp-load.php');

    //$admin_email = get_bloginfo('admin_email');
    $blogid = get_blog_details($_POST['blogname']);
    $blogid = $blogid->blog_id;

    $admin_email = get_blog_option($blogid, 'admin_email' );

    //$to = $_POST['useremail'] . ',' . $admin_email .' youcanhardcode@youremail.com;

    $to = $_POST['useremail'] . ',' . $admin_email;
    $subject = 'Message For You';
    $headers = "From: noreply@domain.com\r\n";
    $headers .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $message = "Blog url: ".$_POST['blogurl']."
    Username: ".$_POST['username']."
    Subscription: ".$_POST['subscriptionname']."
    Membership Level: ".$_POST['levelname']."
    " ;
    mail($to, $subject, $message, $headers);
    ?>

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.