Basic Syntax
// Send a message to a specific user
init_plugin_suite_user_engine_send_inbox(
$user_id, // Recipient user ID
$title, // Message title
$content, // Message content (basic HTML allowed)
$type, // Message type (e.g., 'system', 'gift', 'woo_reward'...)
$metadata, // Optional metadata (array), used for analysis or linking
$expire_at, // Expiry time (timestamp or null)
$priority, // Priority level: 'high', 'normal', 'low'
$link, // Clickable link in the message (if any)
$pinned // Whether to pin the message (0 or 1)
);
Simple Example: Welcome Message
// Send a welcome message when user registers
add_action( 'user_register', function( $user_id ) {
init_plugin_suite_user_engine_send_inbox(
$user_id,
__( 'Welcome to the community!', 'init-user-engine' ),
__( 'Wishing you an amazing journey with us.', 'init-user-engine' ),
'welcome'
);
});
Send Message with Metadata
// Send reward notification after WooCommerce order
init_plugin_suite_user_engine_send_inbox(
$user_id,
__( 'Thank you for your purchase!', 'init-user-engine' ),
sprintf( __( 'You received +%d EXP and +%d coins for your order.', 'init-user-engine' ), $exp, $coin ),
'woo_reward',
[ 'order_id' => $order_id ], // attached metadata
null,
'normal',
$order->get_view_order_url()
);
Send Message with Expiry
// Promotion expires in 24 hours
$expire = time() + DAY_IN_SECONDS;
init_plugin_suite_user_engine_send_inbox(
$user_id,
__( 'Special offer just for today!', 'init-user-engine' ),
__( 'Grab the deal before it expires.', 'init-user-engine' ),
'promo',
[],
$expire
);
Send Pinned Message
// Send an important pinned message
init_plugin_suite_user_engine_send_inbox(
$user_id,
__( 'Important Notice', 'init-user-engine' ),
__( 'Please update your account information.', 'init-user-engine' ),
'alert',
[],
null,
'high',
home_url( '/account' ),
1 // Pinned
);
Send to Multiple Users
// Broadcast to multiple users using the helper function
$user_ids = [2, 3, 4]; // Array of user IDs
init_plugin_suite_user_engine_send_inbox_to_users(
$user_ids,
__( 'Upcoming Event!', 'init-user-engine' ),
__( 'We are launching a new feature soon. Stay tuned.', 'init-user-engine' ),
'event'
);
Conclusion
The init_plugin_suite_user_engine_send_inbox() function is a powerful and flexible tool that lets you actively interact with users through Init User Engine’s inbox system. Sending messages not only increases engagement but also enables many automation scenarios such as rewards, reminders, alerts, marketing campaigns, and more.
If you’re building a behavior or reward-based system, use the Inbox feature to make sure your messages always reach users in a clear and professional manner.
Comments