Title: Duplicating a function
Last modified: August 22, 2016

---

# Duplicating a function

 *  [rickyrick09](https://wordpress.org/support/users/rickyrick09/)
 * (@rickyrick09)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/duplicating-a-function/)
 * 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)

 *  [Chitcher1](https://wordpress.org/support/users/chitcher1/)
 * (@chitcher1)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/duplicating-a-function/#post-5870484)
 * 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.

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 1 reply
 * 2 participants
 * Last reply from: [Chitcher1](https://wordpress.org/support/users/chitcher1/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/duplicating-a-function/#post-5870484)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
