Community Support Forums — WordPress® ( Users Helping Users ) — 2011-09-27T13:33:52-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=15164 2011-09-27T13:33:52-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15164&p=41708#p41708 <![CDATA[Re: Outstanding Issues & Code Share]]>
There is further detail and a code sample available in your Dashboard, under:
s2Member -> API Scripting -> Remote Operations API.
remote-ops-api.png
As another alternative, you could try the Hook user_register, which is what lies beneath these other Hooks/Filters, as part of the WordPress core. See: http://codex.wordpress.org/Plugin_API/A ... r_register Setting a Hook priority to a high number would ensure that your custom routine runs last, after all other processing has taken place.
Code:
<?php add_action("user_register", "my_function", 1000); ?>

Statistics: Posted by Jason Caldwell — September 27th, 2011, 1:33 pm


]]>
2011-09-24T22:37:27-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15164&p=39033#p39033 <![CDATA[Re: Outstanding Issues & Code Share]]>
Maybe you can have your site work without the auto-login after registration for now?

Statistics: Posted by Cristián Lávaque — September 24th, 2011, 10:37 pm


]]>
2011-09-23T09:09:22-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15164&p=38964#p38964 <![CDATA[Re: Outstanding Issues & Code Share]]> Statistics: Posted by seofeed — September 23rd, 2011, 9:09 am


]]>
2011-09-20T21:39:09-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15164&p=38838#p38838 <![CDATA[Re: Outstanding Issues & Code Share]]> Statistics: Posted by Cristián Lávaque — September 20th, 2011, 9:39 pm


]]>
2011-09-20T12:01:06-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15164&p=38731#p38731 <![CDATA[Re: Outstanding Issues & Code Share]]> Statistics: Posted by seofeed — September 20th, 2011, 12:01 pm


]]>
2011-09-16T08:40:04-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15164&p=37311#p37311 <![CDATA[Outstanding Issues & Code Share]]>
1. When user is created an email isn't sent to admin
2. The user isn't added to our email list

Both of these things work fine within the S2Member system but outside of it and they don't work. The two scenarios are auto login after registration and when creating a member from the outside.

For #1 above:

In other words, wp_new_user_notification only sends to the user and not the admin.

For #2 above:

I don't know the call to make the list functions work. Of course, I can tap into MailChimp's API myself if necessary but it would be a lot easier to use to use S2Members' functions.

How can I make sure the admin gets the email they usually get? How can we make sure they are added to the list?

And for the code share:

Here's my auto login code (thanks to Christian):

Code:
add_action('ws_plugin__s2member_during_configure_user_registration_front_side_free', 's2_auto_login_after_registration');
function s2_auto_login_after_registration($vars = array()) {
    if (!is_admin() && $vars['processed'] === 'yes') {
        wp_new_user_notification($vars['user_id'], $vars['pass']);
        wp_set_auth_cookie($vars['user_id'], false, is_ssl());
      wp_redirect('http://domain.com/download-' . $vars['__refs']['level']);
        exit();
    }
}


Here's my create/update user code from outside of S2Member. In this case, we have an XML notification posted this file and it creates a user or updates an existing one. This is useful stuff:

Code:
require('wp-blog-header.php');

$xml = simplexml_load_file("xml.xml");

$orderID = $xml->orderID;
$role = getProductID($xml->lineItems->item->product->productID);
$firstName = $xml->paymentInfos->paymentInfo->customerFirstName;
$lastName = $xml->paymentInfos->paymentInfo->customerLastName;
$email = $xml->paymentInfos->paymentInfo->customerEmail;
$fullName = $firstName . " " . $lastName;
$autoEOT = mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y")+1);

if(!email_exists($email)) {
   
   $random_password = wp_generate_password(8, false);
   $generatedID = wp_create_user($email, $random_password, $email);
   
   if ($role == "s2member_level1") {
      
         wp_update_user( array ('ID' => $generatedID,
                     'first_name' => $firstName,
                     'last_name' => $lastName,
                     'user_email' => $email,
                     'user_login' => $email,
                     'user_nicename' => $email,
                     'display_name' => $fullName,
                     'user_registered' => date('Y-m-d H:i:s'),
                     'role' => $role   
               ) ) ;
      
   update_user_meta($generatedID, 'wp_s2member_auto_eot_time', date("U", $autoEOT));
   update_user_meta($generatedID, 'wp_s2member_custom', 'domain.com');
   update_user_meta($generatedID, 'wp_s2member_subscr_id',  (int)$orderID);
   
      
   } else {
      
         wp_update_user( array ('ID' => $generatedID,
                     'first_name' => $firstName,
                     'last_name' => $lastName,
                     'user_email' => $email,
                     'user_login' => $email,
                     'user_nicename' => $email,
                     'display_name' => $fullName,
                     'user_registered' => date('Y-m-d H:i:s'),
                     'role' => $role   
               ) ) ;
               
   update_user_meta($generatedID, 'wp_s2member_custom', 'domain.com');
   update_user_meta($generatedID, 'wp_s2member_subscr_id',  (int)$orderID);
      
   }
               
   wp_new_user_notification($generatedID, $random_password);
   
   
} else {
   
   if ($role == "s2member_level1") {
      
      $currentID = email_exists($email);
      
         wp_update_user( array ('ID' => $currentID,
                     'first_name' => $firstName,
                     'last_name' => $lastName,
                     'user_email' => $email,
                     'user_login' => $email,
                     'user_nicename' => $email,
                     'display_name' => $fullName,
                     'role' => $role
                     
               ) ) ;
                           
   update_user_meta($currentID, 'wp_s2member_auto_eot_time', date("U", $autoEOT));
   update_user_meta($currentID, 'wp_s2member_subscr_id',  (int)$orderID);   

               
   } else {
      
      $currentID = email_exists($email);
      
         wp_update_user( array ('ID' => $currentID,
                     'first_name' => $firstName,
                     'last_name' => $lastName,
                     'user_email' => $email,
                     'user_login' => $email,
                     'user_nicename' => $email,
                     'display_name' => $fullName,
                     'role' => $role
                     
               ) ) ;
               
   update_user_meta($currentID, 'wp_s2member_subscr_id',  (int)$orderID);
   delete_user_meta($currentID, 'wp_s2member_auto_eot_time');

   }
   
   
}

function getProductID($id) {

   if ($id == "235875900") {
      return "s2member_level1";
   }
   if ($id == "235876000") {
      return "s2member_level2";
   }
   if ($id == "235876100") {
      return "s2member_level3";
   }
   if ($id == "235876200") {
      return "s2member_level4";
   }
   if ($id == "235876300") {
      return "s2member_level5";
   }

}



Statistics: Posted by seofeed — September 16th, 2011, 8:40 am


]]>