0

WordPress user profile page uses the administration interface, and its user registration / login page is not part of the theme. I would like to

  1. change it into the custom theme of my site
  2. customize login / registration page, hopefully with a custom form, and captcha
  3. remove the top bar when the user is logged on
  4. retain this top bar functionality, and administration interface access for administrators and contributors (because I'm using 'Debug Bar' plugin, which is a part of the top bar)
  5. for the rest of regular users, just hide the dashboard (technically make it inaccessible even if URL is entered), and use the profile page with site theme.

How do I achieve this? I'd like to use filters/hooks and maybe create a custom plugin. I prefer not to change the code of WordPress itself.

Thank you.

1
  • I wonder why you want to do this yourself when there are a ton of plugins that do this (perfectly). One of such which we use for our client is ProfilePress (profilepress.net). They have a free version(wordpress.org/plugins/ppress) which should suite your need.
    – W3Guy
    Commented Sep 21, 2016 at 3:36

2 Answers 2

7

This certainly can be done, but it requires some work. I am developing a pretty complex plugin for a client, and I plan to expand on it and make it available publicly when it is ready.

Telling you everything would take ages, so I will just give you some pointers on how you can achieve what you are aiming for.

  1. Make a page called "Profile" and use a custom template in your theme to style the page and add the functionality you wish to. Use the filter login_redirect to redirect your users on their profile pages (or wherever you wish, not on the backend).

  2. Use and customize your login form with wp_login_form. If you want to customize the standard WP form, take a look at the in-depth tips on the codex. You can find all the hooks, CSS classes, ids, and so on for easy reference. Creating a custom registration form is going to be more tricky: your best friends in this process? wp_insert_user and wp_verify_nonce.

  3. There is a meta option associated with the user which decides whether or not the admin bar should be shown. You can edit it from the backend, or programmatically (e.g. on new user registration) like this update_user_meta( $user, 'show_admin_bar_front', 'false' );

  4. Check for your user role, and refer to show_admin_bar.

  5. Check for your user role and consider using wp_redirect (remember to exit!)

This should give you enough info and references to get going by yourself, but if you need any more specific help, feel free to ask.

1
  • Thank you very much for the detailed information. It was quite helpful!
    – He Shiming
    Commented Feb 7, 2013 at 17:50
1

1. Read 2 :)

2. You can check this post - http://digwp.com/2010/12/login-register-password-code/ If you don't want tabs, you can make three diffrent page templates with forms for Login, Register and Lost Password. Then create three pages that use this templates.

3 and 4. This code will show top admin bar only for Admins and Editors:

if (!current_user_can('edit_posts')) {
    add_filter('show_admin_bar', '__return_false');
}

5. With this code only admins and editors will have access to wp-admin. If someone that is subscriber or not loged in will see error 404.

function access_admin_init() {
if ( !current_user_can('edit_posts') && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
    global $wp_query;
    $wp_query->set_404();
    status_header( 404 );
    get_template_part( 404 );
    exit;
   }
}
add_action( 'init', 'access_admin_init' );
2
  • Thank you for your input. It's very nice of you to provide these code.
    – He Shiming
    Commented Feb 7, 2013 at 17:52
  • instead of add an action to 'init' is better to 'admin_init'
    – user48022
    Commented Feb 22, 2014 at 22:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.