Solved

changing role using s2member conditional shortcode

Posted on 2011-09-16
3
594 Views
Last Modified: 2012-05-12
I'm trying to use the following conditional inside a page but it seems the php code is still being executed inside the shortcode when admin hits the page:

[s2If current_user_is_not(administrator)]
[s2If current_user_is(s2member_level0)]
<?php $user = new WP_User(wp_get_current_user()->ID);
$user->set_role("s2member_level1"); ?>
[/s2If]
[/s2If]

does it look correct? I do have php execution plugin installed on the server.

If admin hits the page and that code executes, then admin role gets downgraded to level 1 which is not what I want.

Any suggestions?
0
Comment
Question by:COwebmaster
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
Sudaraka Wijesinghe earned 500 total points
ID: 36554184
According to the WP documentation there's a problem in nesting same type of short codes.
http://codex.wordpress.org/Shortcode_API#Nested_Shortcodes

I'm not familiar with the s2member plugin, maybe you an combine the two conditions using AND operator?
0
 

Author Comment

by:COwebmaster
ID: 36554955
I tried that but is still downgrades the admin to level 1
0
 

Author Closing Comment

by:COwebmaster
ID: 36570601
Thanks!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question