{"action":"created","issue":{"url":"https://api.github.com/repos/websharks/s2member-kb/issues/13","labels_url":"https://api.github.com/repos/websharks/s2member-kb/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/websharks/s2member-kb/issues/13/comments","events_url":"https://api.github.com/repos/websharks/s2member-kb/issues/13/events","html_url":"https://github.com/websharks/s2member-kb/issues/13","id":52795263,"number":13,"title":"How can I specify a future start date for a recurring subscription (aka Custom EOT)?","user":{"login":"raamdev","id":53005,"avatar_url":"https://avatars.githubusercontent.com/u/53005?v=3","gravatar_id":"","url":"https://api.github.com/users/raamdev","html_url":"https://github.com/raamdev","followers_url":"https://api.github.com/users/raamdev/followers","following_url":"https://api.github.com/users/raamdev/following{/other_user}","gists_url":"https://api.github.com/users/raamdev/gists{/gist_id}","starred_url":"https://api.github.com/users/raamdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raamdev/subscriptions","organizations_url":"https://api.github.com/users/raamdev/orgs","repos_url":"https://api.github.com/users/raamdev/repos","events_url":"https://api.github.com/users/raamdev/events{/privacy}","received_events_url":"https://api.github.com/users/raamdev/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/websharks/s2member-kb/labels/draft","name":"draft","color":"eb6420"},{"url":"https://api.github.com/repos/websharks/s2member-kb/labels/pro","name":"pro","color":"009800"},{"url":"https://api.github.com/repos/websharks/s2member-kb/labels/pro-form+customizations","name":"pro-form customizations","color":"bfdadc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2014-12-24T04:32:50Z","updated_at":"2015-01-14T22:52:17Z","closed_at":null,"body":"Let's say you have a site that offers a yearly membership and you're about to invite a bunch of people to sign up (or you have an existing membership base who you're going to invite to renew their subscription). However, you want all your members to start their recurring subscription on the same date.\r\n\r\nFor example, let's say today is January 1st, 2015 and you want everyone who signs up between now and February 1st to have their recurring annual subscription start on February 1st, 2015. That means their annual subscription will expire on February 1st, 2016.\r\n\r\nYou want to let them signup (or renew) between now and February 1st, but you don't want their annual subscription date to really _start_ until February 1st.\r\n\r\n### Dynamic Trial Period\r\n\r\nWhat we can do is utilize the s2Member Pro-Form \"Trial Period\". We will charge members for 1 year when they sign up, but we give them free access between now (when they sign up) and February 1st. \r\n\r\nThe trick is calculating how many days exist between now (when the member is signing up / renewing) and the \"start\" of our annual cycle (February 1st, in this example). To do that, we use the following PHP code. You'll need to place this code inside your Post / Page, right above your Pro-Form. \r\n\r\n_Note: You will need to be running the [ezPHP](http://wordpress.org/plugins/ezphp/) plugin to allow running PHP code directly inside WordPress Posts / Pages._\r\n\r\n```php\r\n<?php\r\n// Change these to the date you want the annual cycle to officially start \r\n$cycle_start_year = '2015';\r\n$cycle_start_month = '2';\r\n$cycle_start_day = '1';\r\n\r\n$cdate = mktime(0, 0, 0, $cycle_start_month, $cycle_start_day, $cycle_start_year);\r\n$today = time();\r\n$difference = $cdate - $today;\r\nif ($difference < 0) { $difference = 0; }\r\n$trial_days = floor($difference/60/60/24); // Calculated number of days until yearly cycle should start\r\n?>\r\n```\r\n\r\nBe sure to change the `$cycle_start_year`, `$cycle_start_month`, and `$cycle_start_day` values to the appropriate date.\r\n\r\nNow, we just need to modify the Pro-Form shortcode to include a dynamic Trial Period attribute (`tp=\"\"`). You'll do that by setting it to `tp=\"<?php echo $trial_days; ?>\"`. Be sure that the Trial Term is set to Days (`tt=\"D\"`) and if you want to make this dynamic trial period free (i.e., you only want to charge the member for 1 year, not 1 year + some amount for the trial period), then set the Trial Amount to zero (`ta=\"0\"`).\r\n\r\n_For more details about the various Pro-Form shortcode attributes, see **Dashboard → s2Member (Pro) → PayPal Pro-Forms → Shortcode Attributes (Explained)**._\r\n\r\nThat's it! Now when someone signs up, they will be charged for 1 year of access and they will be granted access immediately upon successful payment. However, their subscription won't actually expire until 1 year from the \"cycle start\" date that you defined in the PHP code.\r\n\r\n---\r\n\r\n### Complete Example PayPal Pro-Form with Dynamic Trial Amount\r\n\r\n```\r\n\r\n<?php\r\n// Change these to the date you want the annual cycle to officially start \r\n$cycle_start_year = '2015';\r\n$cycle_start_month = '2';\r\n$cycle_start_day = '1';\r\n\r\n$cdate = mktime(0, 0, 0, $cycle_start_month, $cycle_start_day, $cycle_start_year);\r\n$today = time();\r\n$difference = $cdate - $today;\r\nif ($difference < 0) { $difference = 0; }\r\n$trial_days = floor($difference/60/60/24); // Calculated number of days until yearly cycle should start\r\n?>\r\n\r\n[s2Member-Pro-PayPal-Form level=\"1\" ccaps=\"\" desc=\"$100.00 USD / Yearly (recurring charge, for ongoing access)\" ps=\"paypal\" lc=\"\" cc=\"USD\" dg=\"0\" ns=\"1\" custom=\"example.com\" ta=\"0\" tp=\"<?php echo $trial_days; ?>\" tt=\"D\" ra=\"1.00\" rp=\"1\" rt=\"Y\" rr=\"1\" rrt=\"\" rra=\"2\" accept=\"paypal\" accept_via_paypal=\"paypal\" coupon=\"\" accept_coupons=\"0\" default_country_code=\"\" captcha=\"0\" /]\r\n```"},"comment":{"url":"https://api.github.com/repos/websharks/s2member-kb/issues/comments/70008932","html_url":"https://github.com/websharks/s2member-kb/issues/13#issuecomment-70008932","issue_url":"https://api.github.com/repos/websharks/s2member-kb/issues/13","id":70008932,"user":{"login":"raamdev","id":53005,"avatar_url":"https://avatars.githubusercontent.com/u/53005?v=3","gravatar_id":"","url":"https://api.github.com/users/raamdev","html_url":"https://github.com/raamdev","followers_url":"https://api.github.com/users/raamdev/followers","following_url":"https://api.github.com/users/raamdev/following{/other_user}","gists_url":"https://api.github.com/users/raamdev/gists{/gist_id}","starred_url":"https://api.github.com/users/raamdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raamdev/subscriptions","organizations_url":"https://api.github.com/users/raamdev/orgs","repos_url":"https://api.github.com/users/raamdev/repos","events_url":"https://api.github.com/users/raamdev/events{/privacy}","received_events_url":"https://api.github.com/users/raamdev/received_events","type":"User","site_admin":false},"created_at":"2015-01-14T22:52:17Z","updated_at":"2015-01-14T22:52:17Z","body":"@garethwyndavies I just copy/pasted your code into my test install for s2Member and it's working as expected.\r\n\r\nI also have this line underneath my shortcode, just to see what value the `tp=\"\"` attribute is being set to:\r\n\r\n```php\r\n<?php echo \"days: \". $trial_days; ?>\r\n```\r\n\r\nWhen I view the page, it shows `days: 354`, which looks correct to me. That's setting up the form with 354 days as a trial period.\r\n\r\nI'm using PHP 5.4.10, so I don't think your issue has anything to do with the PHP version. "}}