How to create and retrieve data from a special registration form?

What is the recommended way to approach the follow issue? I have to create two pages. On one page I will have a small form where users will be able to register themselves (with or without photo). On the other page, I will show all the users’ info entered on the previous form. For the admin section, I just need to have all the registered users listed and to be able to delete them.

I don’t want to touch the default’s WP user registration stuff, because it is already being used and I cannot mix up the things.

Read More

Is it possible to use some kind of custom post types? Any plugin or idea?

Related posts

Leave a Reply

2 comments

  1. The following code creates a new role. In fact is simply clones the subscriber role, so if you are not using that role currently, you may as well just use that.

    The following function need only be run once (it run’s when a user is ‘admin side’)

    //Creates a custom role called 'my_new_role'.
    //Run this once then feel free to comment out the next line:
    add_action('admin_init', 'my_custom_role');
    function my_custom_role(){
        global $wp_roles;
    
        $subscriber = $wp_roles->get_role('subscriber');
    
        //Adding a 'new_role' with subscriber caps
        $wp_roles->add_role('my_new_role', 'My New Role', $subscriber->capabilities);
        //Optional add/remove caps, like the capability to access the dashboard
        //$wp_roles->remove_cap('my_new_role','read');  
    }
    

    See the codex for more information on capabilities.

    Wherever your are processing the form you’ll want to create a new user and assign them the role ‘my_new_role’. To do this use the wp_insert_user. As a brief example:

    wp_insert_user( array (
        'user_login' => 'JoeBloggs',
        'user_pass' => 'a_password_43463', 
        'first_name' => 'Joseph',
        'last_name' => 'Bloggs',
        'role'=>'my_new_role') ) ;
    

    Prior to the above you should have performed all the nonce-checks, data validation and any other checks.

    You may wish to redirect these new users to a different page (not the dashboard) when they log-in. To do this use the login_redirect filter.

    add_filter('login_redirect', 'dashboard_redirect');
    function dashboard_redirect($url) {
        global $current_user;
        get_currentuserinfo();
    
        if (current_user_can('my_new_role')) {
                 //current user is 'my_new_role', take them somewhere else...
                 $url = home_url(); 
            }
            return $url;
        }
    
  2. I would face it this way:

    Database extension for wordpress allow you to manage very easily the content, you just need to create the form(s) and then you can retrieve and modify the information as you wish. For the other page, since the extension shows you the path to the database, you just need to make some queries and you are done.