Title: Shortcode nested in shortcode paypal button
Last modified: August 22, 2016

---

# Shortcode nested in shortcode paypal button

 *  [amicone](https://wordpress.org/support/users/amicone/)
 * (@amicone)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-nested-in-shortcode-paypal-button/)
 * Hallo,
    i’m setting up a new website using s2members (free version at the moment).
   The products I want to sell are CV profiles and i want to sell them individually,
   i ‘m using custom capabilities to enable who buys that specific profile to view
   the full profile.
 * In other words I need one different paypal payment button for each profile.
 * The problem is: how can I set up a custom price (ra=”custom”) since in case I
   decide to change the profile price i would have not to change individually all
   the profile prices?
 * I thought to use a constant defined in a shortcode but the shortcode nested in
   the paypal shortcode button does not work.
    I tried to use also php instead of
   a shortcode and this would work but in my case it is not useful since the profile
   has to be synchronized from a third party application that writes only in the
   visual mode (and not in the html mode).
 * Can anyone help me to nest a shortcode inside shortcode paypal button?
 * Thanks in advance
 * [https://wordpress.org/plugins/s2member/](https://wordpress.org/plugins/s2member/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Sam Rohn](https://wordpress.org/support/users/sam-rohn/)
 * (@sam-rohn)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-nested-in-shortcode-paypal-button/#post-5899092)
 * how about wp do_shortcode function in a template ?
 * [http://codex.wordpress.org/Function_Reference/do_shortcode](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
 *  Thread Starter [amicone](https://wordpress.org/support/users/amicone/)
 * (@amicone)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-nested-in-shortcode-paypal-button/#post-5899127)
 * 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
 *  [krumch](https://wordpress.org/support/users/krumch/)
 * (@krumch)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-nested-in-shortcode-paypal-button/#post-5899138)
 * 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. 🙂
 *  Thread Starter [amicone](https://wordpress.org/support/users/amicone/)
 * (@amicone)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-nested-in-shortcode-paypal-button/#post-5899142)
 * 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
 *  [krumch](https://wordpress.org/support/users/krumch/)
 * (@krumch)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-nested-in-shortcode-paypal-button/#post-5899199)
 * Without the exactly error message, I can think only that you have a syntax error
   somewhere…
 *  Thread Starter [amicone](https://wordpress.org/support/users/amicone/)
 * (@amicone)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-nested-in-shortcode-paypal-button/#post-5899217)
 * 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
 *  Thread Starter [amicone](https://wordpress.org/support/users/amicone/)
 * (@amicone)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-nested-in-shortcode-paypal-button/#post-5899220)
 * 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/just-wp-variables/)
   [https://wordpress.org/plugins/ezphp/](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

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Shortcode nested in shortcode paypal button’ is closed to new replies.

 * ![](https://ps.w.org/s2member/assets/icon-256x256.png?rev=980067)
 * [s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions](https://wordpress.org/plugins/s2member/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/s2member/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/s2member/)
 * [Active Topics](https://wordpress.org/support/plugin/s2member/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/s2member/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/s2member/reviews/)

## Tags

 * [nested shortcode](https://wordpress.org/support/topic-tag/nested-shortcode/)
 * [s2members](https://wordpress.org/support/topic-tag/s2members/)

 * 7 replies
 * 3 participants
 * Last reply from: [amicone](https://wordpress.org/support/users/amicone/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-nested-in-shortcode-paypal-button/#post-5899220)
 * Status: not resolved