• Resolved fran330

    (@fran330)


    First of all: Great plugin πŸ™‚

    I just noticed a problem though. I don’t know if it’s me misusing it or if it’s a bug.
    Only me as admin can insert a snippet containing a variable. When an editor tries, he gets the icon in the editor and can insert the snippet BUT after he saved the page, the snippet has disappeared. I also checked the page in text view and indeed no snippet there.

    Same with a page in which I inserted a snippet as admin. As soon as the editor edit and saves that page (not touching the snippet), the snippet vanishes.

    More info:
    – I use WP 4.0
    – I use the snippet with variable for google maps and Vimeo or youtube videos.
    Snippet name: iframe etc
    Variable: code
    Shortcode not ticked
    snippet: <center>{code}</center>

    Example of a page with the snippet still there (Google map): http://fr.yoga-laurence-lhermitte.be/les-cours/cours-collectifs-pour-enfants-viniyoga/

    Can you help?

    https://wordpress.org/plugins/post-snippets/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    After the snippet has been posted to the editor, it is out of the plugin’s control. What you are seeing here is probably a native feature of WordPress, that users with the Editor role are not allowed to freely add custom HTML, JS etc to posts.

    Ie, see here: http://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table

    So when the editor goes to a post, and saves it, even if it were ok previously when an admin saved it, the editor resaving it will then remove the code.

    That’s the nature of the editor role in WP. You can verify if it relates to the plugin or not, by pasting the code manually into a post, as an editor, and save it, and see if it stays or gets removed.

    What you could do, is to use it as a shortcode instead, that should circumvent the filtering for editors, as no code is actually placed in the posts when using it as a shortcode.

    Thread Starter fran330

    (@fran330)

    Thank you for your thorough explanation, Johan. I understand. As you advised I used shortcodes. I have to forget about variables but it works.
    Thank you very much for your plugin.

    Fran, you can use variables with shortcodes too.

    Thread Starter fran330

    (@fran330)

    Yes but variables with shortcode enounters the same WP problem when the editor edits and saves the page. If the content of the variable is some html code like iframe for instance, WP deletes it anyway.
    Or did I miss something?

    I also just noticed something when trying a variable with shortcode. Even as admin, if the content of the variable is too long, it shows nothing on the front end. (I think it has something to do with the length, I am not sure).

    For instance,
    When I set the variable content to
    <b>Bonjour</b>
    It works perfectly. It shows “Bonjour” in bold.

    But when I set the variable content to (Google map)
    <iframe style="border: 0;" src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d2521.0806778792153!2d4.4045879999999995!3d50.8111439!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x47c3db2ce9861ab3%3A0xf7692459ac5fb52b!2sRue+des+B%C3%A9gonias+55%2C+1170+Watermael-Boitsfort!5e0!3m2!1sfr!2sbe!4v1411590676042" width="300" height="300" frameborder="0"></iframe>
    Nothing is displayed on the front end although the whole shortcode is there on the back end, also in Text view.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Snippet with variable not working for editor’ is closed to new replies.