This topic contains 2 replies, has 3 voices. Last updated by Tim Haines 3 years, 4 months ago.
Topic Author | Topic |
---|---|
Posted: Wednesday Nov 7th, 2012 at 11:09 pm #30987 | |
A great way to customize your s2Member site is to use the Membership Options Page variables that s2Member passes when a user is redirected from protected content (find info on the variables in your Dashboard under s2Member® -> API / Scripting -> Membership Options Page / Variables). In this tutorial I will be using the WordPress Shortcode API to create a clutter-free Membership Options Page with this feature, though you could easily do the same without a Shortcode within your WordPress Page using a plugin to execute PHP, such as PHP Execution. Creating the Shortcode
Not using Shortcodes? Skip this part
Creating a Shortcode with WordPress is fairly easily. You can check out the full API here, but for these purpose, we only need a few lines of code. You can start with the example at WordPress.org:
Now we'll edit the code slightly to get a more suitable Shortcode name, and function call:
Now we have a WordPress Shortcode to test within a page. You can now put [membership_options_vars] within a WordPress Post/Page on your site to test with. Now, lets make the Shortcode do something.
Starting To CodeThere is a lot of functionality within the Membership Options variables. You can find full documentation for the variables within your Dashboard under s2Member® -> API / Scripting -> Membership Options Page / Variables. In this example, we will add some text to the top of the Membership Options Page based on the type of content the user was redirected from, and the level required. To do this, we first need to grab some PHP $_GET[] variables, and see if they exist in the current URL:
Next, we use these variables to decide what to display to the user. In this example, we will display Sorry, that {Content Type} is restricted. You need {s2Member Level/ccap} to access that.:
And that's it! You now have a cool new feature on your Membership Options Page, that you can customize easily. :) Use with [membership_options_vars] If you have any issues, you can leave a comment below. |