/** * Re-implement [wp-members] shortcode tag for status, page, and meta_key attributes. * * NOT intended to replace every possible use of the [wp-members] shortcode. That tag * is obsolete and the ideal would be to replace it accordingly. However, for instances * where that is not practical, this code snippet provides a solution. * * To use this code, copy/paste to your (child) theme's functions.php file or to * where you store custom code snippets (such as a custom plugin file for the site). * * A list of replacement shortcodes * @see https://rocketgeek.com/shortcodes/list-of-replacement-shortcodes/ * * This code snippet * @link https://rocketgeek.com/code-snippets/re-implement-wp-members-shortcode-tag/ */ add_shortcode( 'wp-members', function( $atts, $content, $tag ) { if ( isset( $atts['status'] ) ) { if ( 'in' == $atts['status'] ) { $content = do_shortcode( '[wpmem_logged_in]' . $content . '[/wpmem_logged_in]' ); } if ( 'out' == $atts['status'] ) { $content = do_shortcode( '[wpmem_logged_out]' . $content . '[/wpmem_logged_out]' ); } } if ( isset( $atts['page'] ) ) { $redirect_to = ( isset( $atts['redirect_to'] ) ) ? ' redirect_to="' . $atts['redirect_to'] . '"' : ''; switch ( $atts['page'] ) { case 'login': $content = do_shortcode( '[wpmem_form login' . $redirect_to . ']' . $content . '[/wpmem_form]' ); break; case 'register': $content = do_shortcode( '[wpmem_form register' . $redirect_to . ']' . $content . '[/wpmem_form]' ); break; case 'password': $content = do_shortcode( '[wpmem_form password]' ); break; case 'user-profile': $content = do_shortcode( '[wpmem_profile]' ); break; } } if ( isset( $atts['meta_key'] ) ) { $content = do_shortcode( '[wpmem_field ' . $atts['meta_key'] . ']' ); } return $content; });
Not sure what to do with this code?
You're not a "coder" and don't know what to do? Don't worry! Code Snippets are the basic building blocks of WordPress customization, and once you know the basics, they are simple to use.
Here are some free articles to get you started:
- Using Code Snippets from the Site
- Using a code snippets plugin
- The functions.php File
- Create a plugin file for custom functions
- Create a child theme
- Do not modify plugin files!
For "hands on" help, consider a plugin support subscription or the Pro Bundle.