How do I make a registration link in a WordPress plugin?

I am using a WordPress plugin, WP User Frontend, in which you need to be logged in to use it. If you attempt to use it while not logged in you get a message:

This page is restricted. Please Login to view this page.

Read More

where “Login” is a link.

I would like to change the message to:

Please Register to view this page

in HTML:

<h3><a href="http://example.com/wp-login.php?action=register">Register</a>Please  to view this page.</h3>

where “register” is a link to the registration page, not the login page.

I tried changing this code:

if ( is_user_logged_in() ) {
    $this->post_form( $post_type );
} else {
    printf( __( "This page is restricted. Please %s to view this page.", 'wpuf' ), wp_loginout( get_permalink(), false ) );
}

to

if ( is_user_logged_in() ) {
    $this->post_form( $post_type );
} else {
    printf( __( "Please %s to view this page.", 'wpuf' ), wp_register('', '') );
}

But the result on the page is :

RegisterPlease to view this page.

The Register link is before the rest of the String.

What did I do wrong?

Related posts

Leave a Reply

1 comment

  1. You are missing the third argument that controls output. The API documentation outlines the signature for this method. The reason for the weird output is that wp_register is calling echo during the function call.

    wp_register('', '', false);