Support » Developing with WordPress » Open Privacy Settings Link from Login-Screen in new Tab

  • Hi there.

    I’m having a small own theme (derived from 20-13) in which i also customized the login form.

    I can customize the appearance of automatically included “Privacy Setting” link with my own login-styles.css but not the target of the link – without editing the wp-login.php.

    Is there any way to change it in that manner, that the link to the privace page will be opened in a new tab aka. target=”_blank”?

    As far as i know it is not possible with CSS only, there must be a filter or hook but i can’t find anything.

    Thanks in advance for any hints.


Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Mel Choyce-Dwan


    Hey! There a hook for this:

    Hope that helps πŸ™‚

    Tnank you so far, but honestly i must say that html, css, php….fine. But hooking or filtering in WordPress? Here i am an amateur.

    So, as i haven’t found an example yet, i assume that this filter will apply always whereever the privacy policy link is “called”.

    And this shouldn’t be.

    I want to “redirect” it only from the login-page to a blank tab.

    Any further hints?


    i assume that this filter will apply always whereever the privacy policy link is β€œcalled”.

    Hehe, yep, you assume well πŸ™‚

    The next step would be to find out how to “recognize” where the link is going at the moment it is being filtered. I can give you a hint: WP uses a global PHP var called $pagenow that usually has the current file name. To check it you would need something like:

    if ( isset( $GLOBALS['pagenow'] ) && $GLOBALS['pagenow'] === 'wp-login.php' ) {
        // your code goes here

    Would be a great “first plugin” experience to get it all working πŸ™‚

    • This reply was modified 1 year, 2 months ago by Andrew Ozz.

    Yeah….it WILL be a great experience….when got it done. IF i get it done…

    Wondering why why something like this is hardcoded in the core.
    I don’t wont to use a special plugin (too many plugins are slowing down the page) but want to have it in my child-theme.

    Well, the season holidays are ahead and i have a lot of time…

    Well, this is the easiest/fastest way to “see” which page was loaded. There are other ways of course.

    A more “involved” way would be something like:

    add_action( 'login_head', function() {
        add_filter( 'the_privacy_policy_link', function( $link, $url ) {
            // do stuff
            return $link;
        }, 10, 2 );
    } );

    Yes, this can easily go into an existing “private” plugin or in a child-theme’s functions.php.

    • This reply was modified 1 year, 2 months ago by Andrew Ozz.
    Moderator bcworkz


    Kai – Like what is hardcoded? The link or $page_now? In order to be less confusing to novice users, WP keeps the options outwardly presented to a minimum and makes many choices internally about what will work best for most users. To maintain maximum flexibility in the face of simplicity, filter and action hooks are provided so more advanced users can tailor their installation as they wish without overwhelming the rest of the user base. Thus understanding the use of filters and actions is essential for any advanced WP user.

    Don’t discount Andrew’s “involved” suggestion. There can be cases where the necessary data to determine application simply is not available to your callback. You can selectively call add_filter() directly in code that only executes in the proper context, such as on a template perhaps. Or as Andrew illustrated, within a more specific action hook. Just be sure to add before the filter is applied.

    Your callback, if it is a named function (Andrew is using a closure/anonymous function as callback), can also remove itself from the filter stack just before returning so that it will not be called again for the same filter during the current request. Sort of a require_once effect for filters.

    Happy coding!

    Kai J.


    OK, i have a workaround.

    In my special login-style.css i set

    .login .privacy-policy-page-link {
    		display: none;

    and in my functions.pho i added

    /* Add Privacy in new tab */
    function custom_loginfooter() {
    	if ( function_exists( 'get_privacy_policy_url' ) )
    		$gdprpage = get_privacy_policy_url();
    		echo "<a href='" , $gdprpage , "' target='_blank'>", get_the_title( url_to_postid( $gdprpage )) , "</a>";

    Now it is working as desired.

    But this is a workaround, I still would like to have a “global” filter/action which redirects the privacy page to a blank page.
    Right now i changed it in the site-footer.php of my child theme for all pages other then login.

    But in my opinion it makes no sense to change the desired behaviour at two places.

    My wish would be to keep the site-info untouched and only add a filter into my functions.php to have the privacy page always in a blank tab.

    Any example would be highly appreciatet.

    Thanks guys….

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Open Privacy Settings Link from Login-Screen in new Tab’ is closed to new replies.