Hardcoding S2 shortcode in page template - not being styled by S2?

Hi guys,

Quick question - I’m implementing a Stripe Pro-form into a page template VIA SHORTCODE, rather than in the post editor.

The pro-form is being called, but it isn’t pulling in any of the S2 member css styles - even though I can see the classes when looking at the form in Firebug.

Do I need to do anything to call the S2 styles, or should I not be using the shortcodes outside of the page editor?

I don’t see a function to replace the shortcode?

Here is my code:

<?php $gateway = get_user_option('s2member_subscr_gateway'); ?>

				<?php if ($gateway === 'paypal') : ?>

				<p><strong>It looks like you paid for your PREMIUM subscription via PayPal.</strong></p>

				<p>Hit the 'Unsubscribe' button below and log in to your PayPal account to cancel your recurring subscription.</p>

				<p>Your PREMIUM membership will be downgraded to a FREE membership at the end of your current subscription term.</p>

				<?php echo do_shortcode('[s2Member-PayPal-Button cancel="1" image="default" output="anchor" /]' ) ?>

				<?php elseif ($gateway === 'stripe') : ?>

				<p><strong>It looks like you paid for your PREMIUM subscription via credit/debit card.</strong></p>

				<p>Complete the security validation below, then hit 'Submit Form' to cancel your payments.</p>

				<p>Your PREMIUM membership will be downgraded to a FREE membership at the end of your current subscription term.</p>

				<?php echo do_shortcode('[s2Member-Pro-Stripe-Form cancel="1" desc="This will cancel your account. Are you sure?" unsub="0" captcha="light" /]') ?>

				<?php endif; ?>

Any idea @jaswsinc?

Thanks guys! :slight_smile:

Hi Ross :slight_smile: It sounds like you have s2Member’s JS/CSS Lazy Load feature enabled in the General Options for s2. If that’s the case, then whenever you integrate an s2Member component outside of the WP editor, s2Member has a hard time determining that it should enqueue styles/scripts, because it normally looks at the post content; i.e., if the post content contains a shortcode, then it will enqueue the styles/scripts.

When Lazy Load is enabled, another way s2Member can detect when it should load styles/styles is through an HTML comment. If you add <!--s2member--> to the post content that serves the content you’re developing, that should do the trick.

And another way is to use a WP filter.

<?php // Requires PHP 5.4+. 
add_action('wp_print_scripts', function() {
    if (is_page('example-page-slug')) {
        add_filter('ws_plugin__s2member_lazy_load_css_js', '__return_true');
    }
}, -1);

3 Likes

@jaswsinc - can’t thank you enough! Works a treat!

Hope you’re well, and have a great weekend! :slight_smile: