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.

Trouble Using Variables in Pro Form Shortcode

Home Forums Community Forum Trouble Using Variables in Pro Form Shortcode

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

Topic Author Topic
Posted: Tuesday Jan 1st, 2013 at 6:02 pm #35934

Hi, I’m new to this community and still very much a newbie. I am trying to generate the Pro Form shortcode using the plugin Shortcode Exec PHP.

This plugin generates a shortcode that I insert in the page. The PHP I’ve written then generates the Pro Form shortcode.

The Pro Form shortcode is generating correctly, but the shortcode is being displayed on the page, it is not being parsed. I’ve used this PHP plugin before on other sites and the shortcode is being parsed before it is displayed, so I know it works.

What am I doing wrong.

<?php
date_default_timezone_set('America/New_York');
$days_in_month = date("t");
$price_per_day = round(10/$days_in_month, 2);
$days_left = date('t') - date('j');
$prorated_payment = round($days_left * $price_per_day, 2);
print("[s2Member-Pro-PayPal-Form level=\"1\" ccaps=\"\" desc=\"1A Membership: This month prorated @ \$");
printf("%.2f", $prorated_payment);
print(", then $10.00/Month (recurring charge, for ongoing access)\" ps=\"paypal\" lc=\"\" cc=\"USD\" dg=\"0\" ns=\"1\" custom=\"www.healthsuccesscenter.com\" ta=\"");
printf("%.2f", $prorated_payment);
print("\" tp=\"1\" tt=\"M\" ra=\"10.00\" rp=\"1\" rt=\"M\" rr=\"1\" rrt=\"\" rra=\"2\" accept=\"paypal,visa,mastercard,amex,discover,maestro,solo\" accept_via_paypal=\"paypal\" coupon=\"\" accept_coupons=\"0\" default_country_code=\"\" captcha=\"clean\" /]");
?>

This code prorates the charge for the first month depending on the remaining number of days and inserts the variables into the Pro Form shortcode.

Thanks.

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Tuesday Jan 1st, 2013 at 7:18 pm #35939

Ok, I figured it out. Here is the solution.

date_default_timezone_set('America/New_York');
$days_in_month = date("t");
$price_per_day = round(10/$days_in_month, 2);
$days_left = date('t') - date('j');
$prorated_payment = round($days_left * $price_per_day, 2);
echo do_shortcode('[s2Member-Pro-PayPal-Form level="1" ccaps="" desc="1A Membership: This month prorated @ $' . number_format($prorated_payment,2) . ', then $10.00/Month (recurring charge, for ongoing access)" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="www.healthsuccesscenter.com" ta="' . number_format($prorated_payment,2) . '" tp="1" tt="M" ra="10.00" rp="1" rt="M" rr="1" rrt="" rra="2" accept="paypal,visa,mastercard,amex,discover,maestro,solo" accept_via_paypal="paypal" coupon="" accept_coupons="0" default_country_code="" captcha="clean" /]');

The key is the do_shortcode command.

Happy New Year Everyone!

Posted: Thursday Jan 3rd, 2013 at 2:10 am #36057

Cool. :)

Happy New Year to you too!

Viewing 2 replies - 1 through 2 (of 2 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.