Link to home
Start Free TrialLog in
Avatar of Mike Waller
Mike WallerFlag for United States of America

asked on

changing role using s2member conditional shortcode

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?
ASKER CERTIFIED SOLUTION
Avatar of Sudaraka Wijesinghe
Sudaraka Wijesinghe
Flag of Sri Lanka image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Waller

ASKER

I tried that but is still downgrades the admin to level 1
Thanks!