PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Outstanding Issues & Code Share

s2Member Plugin. A Membership plugin for WordPress®.

Outstanding Issues & Code Share

Postby seofeed » September 16th, 2011, 8:40 am

We've about got S2Member where we need it but I have a couple of outstanding issues I can't get fixed. It's the same two issues for both scenarios.

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: Select all
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: Select all
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";
   }

}



User avatar
seofeed
Registered User
Registered User
 
Posts: 51
Joined: August 10, 2011

Re: Outstanding Issues & Code Share

Postby seofeed » September 20th, 2011, 12:01 pm

Bumping this thread. Really need an answer to these two questions.
User avatar
seofeed
Registered User
Registered User
 
Posts: 51
Joined: August 10, 2011

Re: Outstanding Issues & Code Share

Postby Cristián Lávaque » September 20th, 2011, 9:39 pm

Thanks for pointing out these problems with the hack. I'll ask Jason to help me because I'm not sure myself.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Outstanding Issues & Code Share

Postby seofeed » September 23rd, 2011, 9:09 am

Following up here again. Sorry to be such a hassle but I really need to get these two issues fixed.
User avatar
seofeed
Registered User
Registered User
 
Posts: 51
Joined: August 10, 2011

Re: Outstanding Issues & Code Share

Postby Cristián Lávaque » September 24th, 2011, 10:37 pm

Sorry for the wait. I really haven't had the time to look into this, and Jason is busy with the new release. We'll get to improving the hack eventually.

Maybe you can have your site work without the auto-login after registration for now?
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Outstanding Issues & Code Share

Postby Jason Caldwell » September 27th, 2011, 1:33 pm

You might also take a look at s2Member's Remote Operations API, which provides you with an easy-to-use API call, that creates Users/Members, and also provides options for the email notification.

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: Select all
<?php add_action("user_register", "my_function", 1000); ?>
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot] and 4 guests

cron