Support » Plugin: Code Snippets » Code Snippets plug in dont work

  • Hello all,

    I use Rehub Theme and I recently activate the Code Snippets plug in. Unfortunately I notice that it doesn’t work. I created different new codes Snippets and I also tested the defaults but nothing happens in my website. Also in the function.php file the code is not added (I don’t know if it is necessary to see the code there or not)

    Do you have any idea?

    Thank you a lot !

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @mairh93, this plugin doesn’t alter your functions.php file at all. It stores the snippets in the WordPress database, not in functions.php.

    It’s impossible to know why the snippets aren’t working on your site without knowing more information, such as: what function are you trying to run in your snippet, what settings are you using for that snippet (eg. run everywhere or run on the front end only), and so on. Also, is the snippet active or deactivated?

    Thread Starter mairh93


    Thank you for your time. First of all, I created one function in order to redirect the customers from account page to home page :

    add_filter( 'user_registration_login_redirect', function( $redirect_url, $current_user ) {
                $current_user = (object) $current_user;
                $roles = isset( $current_user->roles ) ? (array) $current_user->roles : array();
                if ( in_array( 'Store Vendor', $roles, true ) ) {
                    $redirect_url = 'https:/';
                if ( in_array( 'Customer', $roles, true ) ) {
                    $redirect_url = '';
                return $redirect_url;
            }, 10, 2 );

    The 2nd function that I tried it was a simplier one, for testing purposes :

    echo ‘<script>alert(“Welcome to Geeks for Geeks”)</script>’;

    The 1st function (redirect) don’t work neither when I use the code snippet plug in nor when I copy paste directly the code to the function.php

    The 2nd function, with the plug in don’t work either. But when I paste the code in the function.php works..

    In the code snippet , the codes are activated and the run everywhere option is checked.
    Let me know if you need another information to provide to you, or if there is something more that I need to check..

    Thanks for the details!

    If the 1st function also doesn’t work when you put it in functions.php, that suggests to me that there is something wrong with the function itself. Putting it into functions.php is a good way to test it, of course – so if a function also doesn’t work when it’s in functions.php, that means you can rule out the Code Snippets plugin as being the cause of it not working.

    I’m not enough of an expert on PHP functions to be able to see what could be wrong with this one, but you could try asking in the Facebook group of this plugin to see if someone else might help:

    For the 2nd function, it’s strange that it does work when it’s in functions.php but not when it’s in Code Snippets. Could you share the entire function, ie. everything you have pasted into the snippet in Code Snippets, verbatim?

    Thread Starter mairh93



    Regarding the 2nd function, below you will find a screenshot with everzthing that I paste in the code snippets :

    I hopw to find a solution!
    Thank you once again for your time!

    Okay so your 2nd one needs to be in the form of a proper function, rather than just the echo command by itself. That’s why it’s not working. The function will also tell WordPress where exactly you want it to run – for example, do you want it to run in the header area, or at the bottom of the page in the footer area, etc.

    I’d recommend a basic function like this:

    function my_script() {
    echo '<script>alert(“Welcome to Geeks for Geeks”)</script>';
    add_action( 'wp_footer', 'my_script' );

    The “add_action” tells WordPress where to run it – in this case, it’s using the “wp_footer” hook, as defined here:

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Code Snippets plug in dont work’ is closed to new replies.