Skip to main content

better_messages_get_member_id

REQUIREMENTS

To be able to implement this guide, you need to learn how to insert PHP snippets to your website.

You can find guide here: WP Beginner

Compatibility
This guide compatible with Better Messages 2.3.11 or higher

This filter allows modifying dynamical detection of user id which is used by those shortcodes:

Example

add_filter( 'better_messages_get_member_id', 'custom_user_id', 10, 1 );

function custom_user_id( $user_id = null ){
// Customly setup user id which will be shortcode pointed to, based on WordPress environment or any other condition

if( is_post() ){
// If shortcode located at post, point it to User ID 3
$user_id = 3;
} else if ( is_page() ){
// If shortcode located at page, point it to User ID 3
$user_id = 4;
}

return $user_id;
}