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.

  • 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. – Collizo4sky Sep 21 '16 at 3:36
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.

  • Thank you very much for the detailed information. It was quite helpful! – He Shiming Feb 7 '13 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' );
  • Thank you for your input. It's very nice of you to provide these code. – He Shiming Feb 7 '13 at 17:52
  • instead of add an action to 'init' is better to 'admin_init' – user48022 Feb 22 '14 at 22:23

protected by Community Dec 4 '17 at 6:18

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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