Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$-2
Switch theme based upon if_user_can, need fix for WP 3.1
The public theme name should be inserted via an Options Framework variable while the if_user_can answer remains constant.
So for example:
$themedir = of_get_option('optf_themedir', 'twentyten' );
function fb_user_theme( $template = '' ) {
if ( current_user_can('edit_options') ) {
$template = 'onlyiol';
}
else {
$template = $themedir;
}
return $template;
}
add_filter('template', 'fb_user_theme');
add_filter('stylesheet', 'fb_user_theme');
Matt Taylor | 05/17/11 at 8:47am
Edit
(2) Possible Answers Submitted...
Note: Matt Taylor felt their question was unanswered, so we granted them a refund.
Note: Matt Taylor requested a refund. They offered this explanation:
"This question deserves a refund because it was never answered."If no one challenges a refund request, then they are automatically granted and proccessed after 48 hours. Admins of this site only review refund requests if someone challenges the request. If you are curious about how we handled previous refund requests, you may read over all refund requests and their challenges.
See a chronological view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-

Last edited:
05/17/11
9:22amUtkarsh Kukreti says:You need to move the $themedir assignment inside the function.
function fb_user_theme( $template = '' ) {
$themedir = of_get_option('optf_themedir', 'twentyten' );
if ( current_user_can('edit_options') ) {
$template = 'onlyiol';
}
else {
$template = $themedir;
}
return $template;
}
add_filter('template', 'fb_user_theme');
add_filter('stylesheet', 'fb_user_theme');
- 05/17/11 9:34am
Matt Taylor says:I tried it in and out and as a hard-coded variable but the theme is still breaking.
With your snippet the active theme (as set in the Appearance tab) is being displayed to users with permission and visitors without the permission only see a blank page.
I attached a screenshot of what the has-permission user is seeing - 05/17/11 9:39am
Utkarsh Kukreti says:Please add
var_dump($themedir);
just after
$themedir = of_get_option('optf_themedir', 'twentyten' ); - 05/17/11 9:39am
Utkarsh Kukreti says:(for debugging).
- 05/17/11 9:51am
Matt Taylor says:string(14) "certifiedcars2" string(14) "certifiedcars2" string(14) "certifiedcars2" string(14) "certifiedcars2" string(14) "certifiedcars2"
- 05/17/11 9:34am
-

Last edited:
05/18/11
8:44amJust Me says:Did you apply the changes to both themes?
- 05/18/11 8:47am
Matt Taylor says:Yes, the function is called via a mu plugin.
- 05/18/11 2:57pm
Just Me says:if you hardcode the twentyten and use the var_dump does it return the right phrase then?
- 05/18/11 8:47am
This question has expired.
Current status of this question: Refunded
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
