How to create custom redirect url to replace existing in adminize plugin

I am figuring how to redirect the url. Via Inspect Element in Mozilla, I found out the link as below:

<a id="mw_title" href="http://yourdomain.com" title="My Site Title" target="_blank">My Workbook</a>

Is there a function that i can write in the child theme to overwrite the existing and redirect it to

http://yourdomain.com/example

and open in same page?

I am using wordpress with child theme and the plugin is adminimize and beginner on this.

Thanks guys and looking forward for your advise.

3 answers

  • answered 2017-06-17 18:21 derHugo

    Redirect in php is done by

    header("Location: yourside.php");
    

    so if you can edit the code called on http://yourdomain.com you can add the line

    header("Location: http://yourdomain.com/example.php");
    

    or something like that.

  • answered 2017-06-17 18:21 Ashkan Ghadimi

    Create a file called .htaccess in the doc root (web/httpdocs or www folder).

    Copy the code below and save it in .htaccess file to redirect http://yourdomain.com to http://yourdomain.com/example

    Redirect 302 / http://yourdomain.com/example
    

    Note: Test it with 302 status, if everything was ok and redirection worked fine, then change it to 301.

  • answered 2017-06-17 18:21 Alex Wong

    Thanks guys !

    You guys are awesome and supportive with prompt respond :)

    I am using a wordpress plugin ( Adminimize ), I would like to hide all wordpress related items and restrict menus in admin dashboard toolbar.

    12 hours ago I read and follow their advice and code one by one to hide all related wp and menu in admin dashboard. As i am a beginner, i realize that it was quite risky to do so.

    Therefore I install that plugin, what i did a moment ago is:

    I enable Dashboard and disable Admin Bar Back End Options, then i added a custom code into my php as below

    // add custom menu in wp menu
    add_action( 'admin_bar_menu', 'custom_wp_toolbar_link', 999 );
    
    function custom_wp_toolbar_link( $wp_admin_bar ) {
        if( current_user_can( 'edit_posts' ) ){
    
            $args = array(
                'id' => 'myworkbook',
                'title' => '<span class="ab-icon"></span><span class="ab-label">'.__( 'Back To Homepage', 'some-textdomain' ).'</span>',
                'href' => 'http://yourdomain.com/my-workbook/',
                'meta' => array(
                    'target' => '_self',
                    'class' => 'myworkbook',
                    'title' => 'My Workbook'
                )
            );
            $wp_admin_bar->add_node($args);
    
        }
    }
    add_action( 'admin_enqueue_scripts', 'custom_wp_toolbar_css_admin' );
    add_action( 'wp_enqueue_scripts', 'custom_wp_toolbar_css_admin' );
    
    function custom_wp_toolbar_css_admin() {
        if( current_user_can( 'edit_posts' ) ){
            wp_register_style( 'add_custom_wp_toolbar_css', plugin_dir_url( __FILE__ ) . 'custom-wp-toolbar-link.css','','', 'screen' );
            wp_enqueue_style( 'add_custom_wp_toolbar_css' );
        }
    }
    

    This is how it looks

    https://prnt.sc/fkzdr3

    It works like a charm ! Please advise shall there anything to improve , passion to learn more.

    TQ all !!