• Resolved dustyryan85

    (@dustyryan85)


    I have been using HESK for years. It has no wordpress plugin which sucks but no support program made for wordpress has its great features.

    I need to use HESK as a bug reporting/tracking system. I have had to devise a way to pass information to HESK from wordpress using this link:

    <a href="https://archtronics.com/support/index.php?a=add&custom1=
    <?php echo $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ?>
    &category=10&name=<?php $current_user = wp_get_current_user();
    echo $current_user->user_firstname . '&nbsp;';
    echo $current_user->user_lastname . '&email=';
    echo $current_user->user_email . '&custom2=';
    echo $current_user->user_login;?>
    &subject=I%20found%20a%20bug!%20Squash%20it%20please." target="_blank">Report a Bug</a>

    That works just fine, but here is the problem.
    I really need the link to be available on every page of each site for logged in users. I figure the best way to do this is to have it appear on the admin bar.

    I am trying to make a simple plugin that will allow me to make this addition to the admin bar and all I have found on the internet are ways to add a static link up there. Example below:

    add_action( 'admin_bar_menu', 'toolbar_link_to_mypage', 999 );
    
    function toolbar_link_to_mypage( $wp_admin_bar ) {
    	$args = array(
    		'id'    => 'my_page',
    		'title' => 'My Page',
    		'href'  => 'https://mysite.com/my-page/',
    		'meta'  => array( 'class' => 'my-toolbar-page' )
    	);
    	$wp_admin_bar->add_node( $args );
    }

    I am not very good in PHP yet and I have tried so many different ways to get my link to work on the admin bar with no success.

    Does anyone know how to get a dynamic link like mine onto the admin bar?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter dustyryan85

    (@dustyryan85)

    Basically I’m asking:

    function custom_toolbar() {
    	global $wp_admin_bar;
    
    	$args = array(
    		'id'     => 'report_button',
    		'title'  => __( 'Report a Bug', 'text_domain' ),
    		'href'   => 'HOW TO GET A DYNAMIC LINK IN HERE',
    		'meta'   => array(
    			'target'   => '_blank',
    		),
    	);
    	$wp_admin_bar->add_menu( $args );
    
    }
    add_action( 'wp_before_admin_bar_render', 'custom_toolbar', 999 );
    Moderator bcworkz

    (@bcworkz)

    function custom_toolbar() {
    	global $wp_admin_bar;
    	$current_user = wp_get_current_user();
    	$url = "https://archtronics.com/support/index.php?a=add&custom1={$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}&category=10&name={$current_user->user_firstname}&nbsp;{$current_user->user_lastname}&email={$current_user->user_email}&custom2={$current_user->user_login}&subject=I%20found%20a%20bug!%20Squash%20it%20please.";
    
    	$args = array(
    		'id'     => 'report_button',
    		'title'  => __( 'Report a Bug', 'text_domain' ),
    		'href'   => $url,
    		'meta'   => array(
    			'target'   => '_blank',
    		),
    	);
    	$wp_admin_bar->add_menu( $args );
    
    }
    add_action( 'wp_before_admin_bar_render', 'custom_toolbar', 999 );

    I think I got that right, let me know if you encounter any problems. Or now that you see the syntax, you may be able to repair any problem yourself ??

    Thread Starter dustyryan85

    (@dustyryan85)

    I knew I had the syntax wrong but for the life of me I couldnt figure out how to fix it lol

    It works perfectly now!!

    Thank you so much! You are awesome!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Trouble adding a custom admin menu link’ is closed to new replies.