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.

Create a shortcode?

Home Forums Community Forum Create a shortcode?

Tagged: ,

This topic contains 2 replies, has 3 voices. Last updated by  cassel 4 years, 1 month ago.

Topic Author Topic
Posted: Monday Nov 12th, 2012 at 7:35 am #31288

HI. I cannot get php to work on my site. Yes – I’ve tried everything – disabling all plugins, default theme, reinstalling S2Member. I’ve tried PHP Execution, Exec-PHP and Raw HTML plugins. Nothing works. The php just displays as text on the page.

But shortcodes do work. So, as a workaround I want to create a shortcode to replace this php:

< ?php if(S2MEMBER_CURRENT_USER_REGISTRATION_DAYS >= 30){ ?>
    Drip content to Members that registered at least 30 days ago.
< ?php } ?>

I’m thinking something along the lines of:

[S2_USER_REGO_DAYS=30]
    Drip content for Members who registered more than 30 days ago
[/S2_USER_REGO_DAYS]

Then I just enter the number of days as required.

So far I have this:

<?php
function s2hack_user_rego_term( $atts ){
	clever stuff here

	}
add_shortcode( 'S2_USER_REGO_DAYS', 's2hack_user_rego_term' );
?>

But, I’m still learning php, so I don’t know how to grab the shortcode variable (eg 30 days), compare it to their rego days and then return true or false.

Could someone please point me in the right direction??

Thank you so much

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Monday Nov 12th, 2012 at 8:29 am #31303

You’re moving in the right direction, I think.

Shortcodes can have attributes, which you wrote in the function ([hilite mono]$atts[/hilite]), but not in the shortcode. http://codex.wordpress.org/Shortcode_API

You could make the shortcode and attribute be: [hilite mono][s2Drip days="30"][/hilite].

Posted: Monday Nov 12th, 2012 at 10:37 am #31317
cassel
Username: cassel

Just in case you might be interested, i had a hack developped to drip content and it uses shortcode. It has the added functionality that it is not based on level registration time but transaction time.
http://www.s2member.com/forums/topic/ccap-drip-timer-drip-multiple-courses/

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.