Instantly share code, notes, and snippets.

Embed
What would you like to do?
CUSTOM PRO SITES MESSAGE FOR NON-PRO SITES USERS | SUPPORT SYSTEM PLUGIN
<?php
/**
* Change to your custom message in line 31 and 53
*/
add_filter( 'support_system_not_allowed_tickets_list_message', 'support_custom_message', 20, 2 );
add_filter( 'support_system_not_allowed_submit_ticket_form_message', 'support_custom_message', 20, 2 );
add_filter( 'support_system_not_allowed_faqs_list_message', 'support_custom_message', 20, 2 );
function support_custom_message( $message, $type ) {
if ( ! is_user_logged_in() )
return $message;
$user_id = get_current_user_id();
$settings = incsub_support_get_settings();
if ( is_multisite() && $settings['incsub_allow_only_pro_sites'] ) {
$pro_blog_id = false;
// Let's check if its main blog is a pro site
$main_blog = get_active_blog_for_user( $user_id );
if ( $main_blog && is_pro_site( $main_blog->blog_id, $settings['incsub_pro_sites_level'] ) ) {
$pro_blog_id = $main_blog->blog_id;
}
else {
$user_blogs = get_blogs_of_user( $user_id );
foreach ( $user_blogs as $blog ) {
if ( is_pro_site( $blog->userblog_id, $settings['incsub_pro_sites_level'] ) ) {
$pro_blog_id = $blog->userblog_id;
break;
}
}
}
if ( $pro_blog_id ) {
$admin_url = add_query_arg( 'page', 'ticket-manager', get_admin_url( $pro_blog_id, 'admin.php' ) );
$message = sprintf( __( 'Need support? <a href="%s" title="%s">Click here to go to your dashboard</a>', INCSUB_SUPPORT_LANG_DOMAIN ), $admin_url, esc_attr( __( 'Go to support in your site dashboard', INCSUB_SUPPORT_LANG_DOMAIN ) ) );
}
}
elseif ( is_multisite() && ! $settings['incsub_allow_only_pro_sites'] ) {
$blog_id = false;
$main_blog = get_active_blog_for_user( $user_id );
if ( $main_blog ) {
$blog_id = $main_blog->blog_id;
}
else {
$user_blogs = get_blogs_of_user( $user_id );
if ( $user_blogs ) {
$blog = key( $user_blogs );
$blog_id = $blog->userblog_id;
}
}
if ( $blog_id ) {
if ( $type == 'faq-list' )
$admin_url = add_query_arg( 'page', 'support-faq', get_admin_url( $blog_id, 'admin.php' ) );
else
$admin_url = add_query_arg( 'page', 'ticket-manager', get_admin_url( $blog_id, 'admin.php' ) );
$message = sprintf( __( 'Need support? <a href="%s" title="%s">Click here to go to your dashboard</a>', INCSUB_SUPPORT_LANG_DOMAIN ), $admin_url, esc_attr( __( 'Go to support in your site dashboard', INCSUB_SUPPORT_LANG_DOMAIN ) ) );
}
}
return $message;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment