logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$20
Replace Register Link with Function

There are a thousand ways to hack the login pages of wordpress. I am looking for the cleanest way anyone knows of to replace the "Register" link to show a modal instead of leading to the wordpress default page.

So this:

<a href="https://mysite.com/wp-login.php?action=register">


needs to become this:

<a href="#myModal7" role="button" data-toggle="modal">




I do not want to edit any core files, nor make copies of core files.

This question has been answered.

Kyle | 02/01/13 at 5:54pm Edit
Tutorial: How to assign prize money


(25) Responses

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    02/01/13
    6:00pm
    Arnav Joy says:

    see this plugin

    http://wordpress.org/extend/plugins/login-with-ajax/

    http://wordpress.org/extend/plugins/modal-register/

    Previous versions of this answer: 02/01/13 at 6:00pm

  • avatar
    Last edited:
    02/01/13
    5:59pm
    Francisco Javier Carazo Gil says:

    Kyle,

    I would make a new sign up form with jQuery UI you can show the modal dialog.

  • avatar
    Last edited:
    02/01/13
    6:04pm
    Dbranes says:

    you could check out the filter 'register' to edit the register link

    I think it could be something like this:

    add_filter('register', 'my_register_link');

    function my_register_link($link){
    // do some stuff with register link
    //
    return $link;
    }

  • avatar
    Last edited:
    02/01/13
    6:08pm
    John Cotton says:

    Have you looked at the site_url filter?

    apply_filters( 'site_url', $url, $path, $scheme, $blog_id );


    You could check in a filter that it was the register link (ie strpos( $url, 'action=register' ) ) and then return your own link the circumstances you want to.

    JC

  • avatar
    Last edited:
    02/01/13
    6:00pm
    Kyle says:

    Hi arnav, thanks for the reply.

    I do not want to change/replace any current functions. My security software does not work with third party plugins.

    Needs to be a function

  • avatar
    Last edited:
    02/01/13
    6:00pm
    Kyle says:

    Hi Javier, thanks for the reply

    Cannot change the whole form, that link only

  • avatar
    Last edited:
    02/01/13
    6:01pm
    Francisco Javier Carazo Gil says:

    Prepare the sign up form directly in HTML into modal dialog with jQuery UI and prepare a script to make the signup:

    $user_id = wp_create_user($name, $password, $email);
    if(is_wp_error($user_id))
    echo "Username already exists. Please try another one.";
    else{
    update_user_meta($user_id, 'address', $address);
    update_user_meta($user_id, 'first_name', $first_name);
    update_user_meta($user_id, 'last_name', $last_name);
    }

    $from = get_option('admin_email');
    $headers = 'From: '.$from . "\r\n";
    $subject = "Registration successful";
    $msg = "Registration successful.\nYour login details\nUsername: $username";
    wp_mail($email, $subject, $msg, $headers);

  • avatar
    Last edited:
    02/01/13
    6:02pm
    Kyle says:

    Unfortunately this will remove the form from the scope of my security software which will cause malware and intrusion risks

  • avatar
    Last edited:
    02/01/13
    6:04pm
    Kyle says:

    I do not want to change any core functions or alter any existing processes. I only want to replace that link

  • avatar
    Last edited:
    02/01/13
    6:06pm
    Francisco Javier Carazo Gil says:

    Kyle,

    No, you can use nonce to protect your forms, I don't know what software of security are you talking about.

    You can use instead then .htaccess:

    RewriteEngine On

    RewriteCond %{QUERY_STRING} ^action=register$ [NC]
    RewriteRule ^wordpress/wp-login.php$ http://www.example.com/wordpress/register? [L,R=301,NC]

    This will redirect http://www.example.com/wordpress/wp-login.php?action=register EXACTLY to http://www.example.com/wordpress/register

  • avatar
    Last edited:
    02/01/13
    6:07pm
    Kyle says:

    Hi Dbranes, thanks for the reply. Something like this is exactly what I am looking for. I tried this but didn't get a result:

    add_filter('register', 'my_register_link');
    function my_register_link($link){

    $link = '<a href="#myModal7" role="button" data-toggle="modal">Register</a>';

    return $link;

    }

    Link is still directing to /wp-login?action=register

  • avatar
    Last edited:
    02/01/13
    6:09pm
    Kyle says:

    My security has its own protective measures that I do not wish to circumvent, so I want to stay with the current process.

    My server doesn't allow for editing htaccess

  • avatar
    Last edited:
    02/01/13
    6:09pm
    Dbranes says:


    ok, have you tried changing the priority:

    add_filter('register', 'my_register_link',99);

  • avatar
    Last edited:
    02/01/13
    6:12pm
    John Cotton says:

    add_filter('register', 'my_register_link');

    That filter doesn't always have the registration link in it (checkout the core code to see why) so you should check it before returning.

    Site url won't either so you would have to check there too, but it's the place where the actual url is being set so feels (to me at least) like the better place to check/change.

  • avatar
    Last edited:
    02/01/13
    6:12pm
    Kyle says:

    Hi John, thanks for the reply

    I need the extra part of the link with the data-toggle="modal" part to execute the modal I believe. I don't think that will execute with the $url hook

  • avatar
    Last edited:
    02/01/13
    6:13pm
    Kyle says:

    Thanks for following up

    I added the 99 but still no result :(

  • avatar
    Last edited:
    02/01/13
    6:14pm
    John Cotton says:

    Fair point.

    Register filter it is!

  • avatar
    Last edited:
    02/01/13
    6:25pm
    Dbranes says:

    It looks like the register function wp_register() is not used everywhere.

    In wp-login.php we have:

    <a href="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login' ) ); ?>"><?php _e( 'Register' ); ?></a>


    and

    <form name="registerform" id="registerform" action="<?php echo esc_url( site_url('wp-login.php?action=register', 'login_post') ); ?>" method="post">


    but not the function wp_register().

    But in /wp-includes/default-widgets.php and in some theme's sidebars.php can we find

    <?php wp_register(); ?>


  • avatar
    Last edited:
    02/01/13
    6:28pm
    Kyle says:

    Okay, yes, I was just looking through the codex too and wondered what it mean when it said included in sidebars. Is there someway to cover both bases?

  • avatar
    Last edited:
    02/01/13
    6:40pm
    Dbranes says:

    ( if you use the Meta widget, then you get wp_register() )

    ... maybe some jQuery tricks to edit links with action=register ?

  • avatar
    Last edited:
    02/01/13
    6:47pm
    Kyle says:

    Hmm, yeah I am only concerned with the link on the login page unfortunately

    I'm not too skilled with jQuery either. I wonder if there is a way to filter/replace the entire #nav paragraph?

  • avatar
    Last edited:
    02/01/13
    6:55pm
    Kyle says:

    What about removing the #nav completely with jquery than inserting my link (and the lost password link) into the footer where the back to blog link is with the login_footer hook?

  • avatar
    Last edited:
    02/01/13
    7:31pm
    Dbranes says:

    ok, here is a toy example (without jQuery) to replace the #nav html code on the wp-login.php page

    add_action('login_footer','my_login_footer');
    function my_login_footer(){
    echo "<script>
    var e = document.getElementById('nav');
    var myhtml = '<a href=\"#myModal7\" role=\"button\" data-toggle=\"modal\">Register (modified)</a> | <a href=\"http://example.com/wp-login.php?action=lostpassword\" title=\"Password Lost and Found\">Lost your password?</a>';
    e.innerHTML= myhtml;
    </script>";
    }

  • avatar
    Last edited:
    02/01/13
    7:37pm
    Kyle says:

    Okay making progress :)

    Very odd result, so when viewing the page markup it looks exactly as it should:

    <a href="#myModal7" role="button" data-toggle="modal">



    However, the actual link is this:

    /wp-login.php?redirect_to=https%3A%2F%mysite.com%2F#myModal7


    Strange

  • avatar
    Last edited:
    02/01/13
    8:01pm
    Kyle says:

    It works!

    I had to re-add the bootstrap js with login_enque_script

This question has expired.



John Cotton, Francisco Javier Carazo Gil, Arnav Joy, Kyle, Naveen Chand voted on this question.



Current status of this question: Completed



Please log in to add additional discourse to this page.





Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.