how about wp do_shortcode function in a template ?
http://codex.wordpress.org/Function_Reference/do_shortcode
you could insert a a var something like this –
<php
do_shortcode('[s2Member-PayPal-Button ra ="' . $variable . '"]');
?>
sam
Thank you Sam for your help.
Anyway my template is too complicate to deal with modification. It’s a listing template and I should change a lot of files.
Can I do something in the functions.php?
I go further a little.
I have one plugin where I define constants
In the visual editor I can recall that constant with a shortcode.
Example.
Constant name = price
I’d like to put in the s2member paypal button
ra=”[price]”
when I do it now it returns errors since s2member plugin is not able to nest the [price] shortcode.
Thank you in advance
There is a possibility to use Sam’s function in s2-hacks.php file, and to include output in the pages by custom shortcode. Means, the PHP function puts whatever you need in s2M’s shortcode, then runs do_shortcode() function to turn it to HTML, and gives that to a your own shortcode function, which places it to the page. Well, recursion… Shortcode hack by shortcode. π
Thank you krumch,
I tried but it gives me an error in the header!
It’s a crucial point for me bec I will have at least 1000 pages and clearly if I’ll change my price plans in the future I do not want to fix the new price on 1000 pages!
Cheers
Without the exactly error message, I can think only that you have a syntax error somewhere…
Hallo I’m just about to reach the goal!
Now I am writing the paypal button directly in the custom template as suggested by Sam and it’s working. I can parse correctly the button, the price, and also I can dynamically assign ccap from the post id. So I have one ccap for each post.
I have just one problem. I am not able to use conditionals inside the custom template, namely, for example to show the button only to logged in users and hide it to who bought the ccap.
I tried to have a look but I was not able to find documentation about how to use conditionals directly in php. I found only very simple cases not working for me.
Do u have any idea on how to deal with s2members shortcodes in php?
Thank a lot in advance
Finally I got it! Wow…..
I managed to run a variable price in paypal button controlled from dashboard so in case I would like to change the price i could do it automatically on every page at once (I have almost 1000 pages). Each page has it’s own ccap automatically generated and based on the post id. The roles and capabilities are respected.
How I got it?
first I widgetized the template. Then i installed 2 plugins:
https://wordpress.org/plugins/just-wp-variables/
https://wordpress.org/plugins/ezphp/
The first one allows to manage variables that one can replace in template widget or posts by means of shortcodes or php.
I needed php to be read in widget so I installed the second plugin.
Now all the code is working properly and s2options for payments etc…. are all in the widget.
Why put the code in widget? Because the php in posts can be read only in text composer but my pages are uploaded via a third party application directly on the Visual composer so I needed to keep separate the content uploaded by the user from the code needed to manage s2member options.
Hope this could help somebody else looking for a similar solution.
Cheers