latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Set EOT time through php

Home Forums Community Forum Set EOT time through php

Tagged: ,

This topic contains 3 replies, has 2 voices. Last updated by  Cristián Lávaque 3 years, 10 months ago.

Topic Author Topic
Posted: Thursday Mar 7th, 2013 at 7:08 am #43941

I’m tryin to write php script that woud set EOT of users with ccaps “review” to certain date.
Managed to find some stuff on forums here : http://www.s2member.com/kb/roles-caps-via-php/
and here : http://www.primothemes.com/forums/viewtopic.php?t=10100&p=21197#p20785

so far this is what i got :

ID);
                        if (##CCAPS OF USER->ID =="review"##)
                            {
                                # set eot
							$expire_on = s2member_registration_time ($user->ID)##+1 YEAR##;
							update_user_option ($user->ID, "s2member_auto_eot_time", $expire_on);
                            }
                    }
                /**/
                exit ();
?>

as you can see i;m missing two pieces of code and wasnt able to google on how to do it

1. ##CCAPS OF USER->ID ==”review”## how to read ccaps in php and check if it is equal to “review”
2. $expire_on = s2member_registration_time ($user->ID)##+1 YEAR##; how to set variable $expire_on to 1 year after registration date ?

Any help woud be mych aprecieated i know those are probably easy things

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Friday Mar 8th, 2013 at 5:53 am #44049

Still tryin to make it work – any thoughts ?
To me it seemd like an easy script but if its to complicated and time consuming to figure out at least showing me the right directions woud be great.

Posted: Saturday Mar 9th, 2013 at 1:10 pm #44165

Managed to put some script pieces i;ve found together. Heres my solution maybe it’ll help someone in the future:

foreach (get_users () as $user)
                  {
                      $user = new WP_User ($user->ID);
				$user_capabilities = get_user_field(s2member_access_ccaps,$user->ID);
                      if ($user_capabilities[0]=="review" && get_user_field(s2member_auto_eot_time,$user->ID)=="")
                          {
              
                              # set eot
					$expire_on = strtotime("+1 year", s2member_registration_time ($user->ID));
					update_user_option ($user->ID, "s2member_auto_eot_time", $expire_on);
					echo $user->ID." ## ".$user_capabilities[0]." ## ".strtotime("+1 year", s2member_registration_time ($user->ID))."<br/>";

                          }
                  }
 exit ();

It basicly sets a EOT of users with ccaps “review” (only if EOT is empty) to a date 1 year after their registration date.

Posted: Sunday Mar 10th, 2013 at 12:53 am #44186

Hi Patryk.

Thanks for sharing your solution. :)

$user_capabilities[0]=="review"

For that condition, you may prefer to use:

[hilite pre_code]
current_user_can('access_s2member_ccap_review')
[/hilite]
Viewing 3 replies - 1 through 3 (of 3 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.