Solved

changing role using s2member conditional shortcode

Posted on 2011-09-16
3
587 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now