Login | Sign up | Toll-Free: 1-800-752-0455



3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 2, 2017

Hi. I'd like to create a wysiwyg_custom.php that will allow one set of TinyMCE toolbar buttons for the admin user, and another set for all other user levels.

For example:

If user is 'admin', they will see these toolbar icons:
toolbar1: "formatselect fontsizeselect | bold italic underline | bullist numlist | charmap | removeformat fullscreen",
toolbar2: "forecolor backcolor | link | table | pastetext paste | code",
toolbar3: '',

All other user levels will see these:
toolbar1: "bold italic | bullist numlist | removeformat fullscreen",
toolbar2: '',
toolbar3: '',

If anyone can tell me how to accomplish this, it would make my world a much better place! :)

~ Deborah

Near the top of your wysiwyg_custom.php you can test if the user is admin:

if (@$CMS_USER['isAdmin']) {
$toolbar1 ="formatselect fontsizeselect | bold italic underline | bullist numlist | charmap | removeformat fullscreen";
$toolbar2= "forecolor backcolor | link | table | pastetext paste | code";
} else [
$toolbar1 ="bold italic | bullist numlist | removeformat fullscreen";
$toolbar2= "";

then in the HTML portion you can set the toolbar(n) to the appropriate variables:

toolbar1: $toolbar1,
toolbar2: $toolbar2,

I haven't test it but that should be close.

Jeff Shields

Jeff, thank you very much for your response!

Here's the final code that works for me with version 3,07:

1) Near top, just before the HTML:

$CMS_USER = getCurrentUserFromCMS();
if ($CMS_USER['isAdmin']){
$toolbar1 ="formatselect fontsizeselect | bold italic underline | bullist numlist | charmap | removeformat fullscreen";
$toolbar2= "link | table | pastetext paste | code";
$toolbar3= "";
else {
$toolbar1 ="bold italic | bullist numlist | link | removeformat fullscreen";
$toolbar2= "";
$toolbar3= "";

2) In the HTML portion, I commented out the existing toolbar lines and added this:

toolbar1: "$toolbar1",
toolbar2: "$toolbar2",
toolbar3: "$toolbar3",

I often need to edit the underlying code of something a user has copied/pasted in a wysiwyg editor, yet I don't want to display the "code" button or most of the other toolbar icons. Thanks again for your help on this!

~ Deborah