WordPress.org

Ready to get started?Download WordPress

Forums

wp_register, how do I change the Text Link (14 posts)

  1. kutu
    Member
    Posted 5 years ago #

    I'm using the template tag <?php wp_register(); ?>

    to generate a link to register as a member however I want to change the before text "Register" and the after text "site admin"

    But when I use the code like this

    <?php wp_register('Sign Up', 'Your Profile'); ?>

    this displays the words Sign up and Your profile not as links and also keeps the Register link..

    so instead of my menu looking like this..

    Home - Community - Log out - Your Profile

    Its all jacked up like this

    Home - Community - Log out - Sign up - Register - Your Profile

    Any ideas on how to properly modify the Register template tag or perhaps a BETTER way to accomplish what I want?

  2. Shane G
    Member
    Posted 5 years ago #

    Hi,

    You can manage the menu either with wordpress emnu template or plugin..ook these for the same:

    http://codex.wordpress.org/Template_Tags/wp_register
    http://wordpress.org/extend/plugins/wp-menu-creator/

    Thanks,

    Shane G.

  3. kutu
    Member
    Posted 5 years ago #

    But the problem is the template tag is not working

    <?php wp_register('Sign Up', 'Your Profile'); ?>

    with the above template tag my menu looks like this

    Home
    Sign up (supposed to be the link you see if you're not signed in)
    Register
    Your Profile (if you're signed)

    As you can see the Sign up is not a link.. the tag is not noticing the variables or I'm using them wrong.. =(

  4. kutu
    Member
    Posted 5 years ago #

    I can change the text if I modify the

    wp-includes/general-template.php

    about line 50

    but then when I upgrade I'll have to clean that file up again..

    anyone know how to use those variable in the <?php wp_register('before', 'after'); ?>

    where before and after need to be custome text

  5. fjudd99
    Member
    Posted 5 years ago #

    Keep in mind that I'm a total PHP noob, but I think the 'before' and 'after' are primarily for formatting for whatever text is going to be displayed there by default. To change the text of the link this works for me:

    if ( is_user_logged_in() ) 
    
        wp_register('<!--','--><li><a href="http://www.mcadusers.com/wp-admin/">Your Dash</a></li>');
    
    else
        wp_register('<!--','--><li><a href="http://www.mcadusers.com/wp-login.php?action=register">Register</a></li>');
    ?>

    Basically I'm commenting out whatever junk wp_register is inserting, then doing my own thing. A simple if/else statement decides what that thing is - in this case if I should override to either lead to the admin page or the register page.

    I think this would also persist after an upgrade, as the change would be made to a theme file (in my case the header).

  6. Arnold Goodway
    Member
    Posted 4 years ago #

    Changing the core files is not the answer as you will have to continually make these changes as the new versions of WordPress appear.

    I wanted to change just the 'Register' link on my site to "Register and Post'. I added the following to my theme's functions.php file:

    add_action( 'register' , 'register_replacement' );
    function register_replacement( $link ){
    	if ( ! is_user_logged_in() ) {
    		if ( get_option('users_can_register') )
    			$link = '
    
  7. ' . __('Register and Post') . '
  8. '; else $link = ''; } else { $link = '
  9. ' . __('Site Admin') . '
  10. '; } return $link; }

    You could easily stick your changes to the Site Admin link in here as well. Hope this helps.

  11. voodochold65
    Member
    Posted 4 years ago #

    I am even more of a noob than i like to admit...

    So please a little more help needed here..

    Beyond putting this function in my Themas functions.php what else do i need to do so that it get's called...and does it matter were ai put it ?

    Also I take it the blue text is were i type my message ?

    Thanks

  12. Casemon
    Member
    Posted 4 years ago #

    @ArnoldGoodway
    Yes it seems like this code should work, & it replaces the Site Admin text, however without the link.

    Any fixes for this?

  13. jonnyplow
    Member
    Posted 4 years ago #

    try this, it worked for me, I used Arnold's code above as a start, but then swapped it with the actual same code as in the general-template.php file.

    add_action( 'register' , 'register_replacement' );
    function register_replacement( $link ){
    	if ( ! is_user_logged_in() ) {
    		if ( get_option('users_can_register') )
    			$link = $before . '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>' . $after;
    		else
    			$link = '';
    	} else {
    		$link = $before . '<a href="' . admin_url() . '">' . __('Your Title Here') . '</a>' . $after;
    	}
    	return $link;
    }
  14. Casemon
    Member
    Posted 4 years ago #

    @jonnyplow
    Worked swimmingly! Thank you! :)

    Am finding replacement filters are very powerful indeed!

  15. shawnymac
    Member
    Posted 4 years ago #

    @jonnyplow
    How do I change the link from 'sitename.com/wp-admin' to 'sitename.com/wp-admin/edit.php' or where do I put the forwarding URL?

    I'm creating new author user accounts and I'm going to completely hide the dashboard from them.

  16. MichaelH
    Member
    Posted 4 years ago #

  17. shawnymac
    Member
    Posted 4 years ago #

    I am using the Peter's Login Redirect. I'll try to give more details.

    In trying to completely hide the dashboard from the authors but there's one problem, let me explain my situation...

    On the home page of my site there's only a 'Log In' link that takes the user to the wp-login.php page and when they log in there, they are redirected to wp-admin/edit.php with the peter's login redirect.

    When the user is logged in and on the edit posts screen, they cannot see the menu for the dashboard which is hidden with this plugin http://wordpress.org/extend/plugins/hide-admin-panels/

    Now to the problem. When the user is logged in and visits the blog, they then now see two links, intentionally, both the 'log out' link and the 'register' link with its replacement text. But, the register link takes the user back to the dashboard.

    How do I redirect the user using the 'register' link to another page other than the dashboard once they're already logged in? I apologize and I probably should have phrased my question better earlier.

  18. ghanshyamk
    Member
    Posted 4 years ago #

    You could acquire this by simply adding edit.php link to the admin_url() in jonnyplow's code.

    add_action( 'register' , 'register_replacement' );
    function register_replacement( $link ){
    	if ( ! is_user_logged_in() ) {
    		if ( get_option('users_can_register') )
    			$link = $before . '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>' . $after;
    		else
    			$link = '';
    	} else {
    		$link = $before . '<a href="' . admin_url() . 'edit.php">' . __('Your Title Here') . '</a>' . $after;
    	}
    	return $link;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.