Using a shortcode to get User Emails by role as specified in the shortcode, need help to allow for multiple roles

If you’re trying to get users with all roles (in your example, administrator and author), your code looks like it should work. If you want users with any role (administrator or author, you’ll need to split the string in the role attribute into an array using explode(), and use the role__in array. Something like this … Read more

How do I create a shortcode that returns a logged in users’ email?

Need to move wp_get_current_user() inside of the shortcode’s callback (untested): function current_user_email_address() { if ( ! is_user_logged_in() ) { return ”; } $user = wp_get_current_user(); if ( empty( $user->user_email ) ) { return ”; } return esc_html( $user->user_email ); } add_shortcode( ‘current_user_email_address’, ‘current_user_email_address’ );

How can I strip a single tag from an email post

The following regex should do the trick to select all instances of the videopack shortcode, including contents: \[videopack.*?\[\/videopack\] $post_description = preg_replace( ‘\[videopack.*?\[\/videopack\]’, ”, $post->post_content ); https://www.php.net/manual/en/function.preg-replace.php https://regexr.com/

How to make my logged-in user-role shortcode displaying name instead of slug?

Based on what you wrote, you should use instead : if ( ! is_admin() ) { function get_user_role() { global $wp_roles; $user = wp_get_current_user(); $roles = ( array ) $user->roles; foreach ( $roles as $role ) { $user_role=”<p>” . $wp_roles->roles[ $role ][‘name’] . ‘</p>’; } return $user_role; } add_shortcode( ‘display_user_role’, ‘get_user_role’ ); } It works … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)