• I found this very useful function which allows you to hide various plugins or even just texts from users that are not logged in.

    function member_check_shortcode($atts, $content = null) {
    if (is_user_logged_in() && !is_null($content) && !is_feed()) {
    return do_shortcode($content);
    }
    return ‘<p>Please register to add content.</p>’;
    }
    add_shortcode(‘member’, ‘member_check_shortcode’);

    *it works along with- [member][plugin-shortcode-here][/member]

    Very useful function. However i notice that when i duplicate it in functions.php to hide a second plugin then my website returns an error.

    How exactly do i duplicate the function, is there a part of the code that i should rename, and if so where exactly?

Viewing 1 replies (of 1 total)
  • In the code world, it is common practice to not duplicate functions. Especially when the function can be reused such as in this case. Instead of duplicating the function you would need to at add additional actions to the “if” statement. Without seeing the do_shortcode() function and seeing where add_shortcode is being used I can’t really tell you much more.

    FYI, i would suggest posting this question on the plugin’s developer page.

Viewing 1 replies (of 1 total)

The topic ‘Duplicating a function’ is closed to new replies.