Support » Plugins » [Plugin: ProjectManager] User Dataset Not Created on New User Registration

  • I’m running Project Manager (, and so far most of it is working like a breeze for what I want to do with it. However, I’ve had one slight snafu come up when trying to use it to extend user profiles: user datasets are not being created when new users register for my blog. I’ve had to manually go in and create a dataset associated with them before they were able to view it on their profile page.

    I’m pretty sure this is a permissions issue, as I tried creating a test user account myself (as administrator) and it had a dataset associated with it right away that it was able to view on its profile. But creating another test user as if I was a visitor registering on the site did not. Both users were created with the same roles, so they should have both seen the same things.

    Any thoughts on how I might be able to fix this, or at least get a better idea of exactly where the problem might be and what might be causing it?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Ok, I was wrong, it doesn’t seem to be permissions. I (temporarily) changed the default user role upon registration to a role that had permission to do absolutely everything relating to Project Manager. When I registered a test account, it still did not have a dataset created for it, though it was able to create a dataset for itself manually. It appears to me that the function for creating a new dataset upon new user registration just isn’t being called when a visitor registers themselves, only when an admin creates a new account for a new user. Still not quite sure how to fix it (I’m thinking of adding a routine to the profile hook that would populate the dataset if blank), but at least it narrows the problem down.

    Ok, if anyone else is experiencing this problem, it’s caused by wp-login.php using wp_create_user instead of user_register.

    Here’s what you do to fix it:

    After line 91 of projectmanager.php, which reads:
    add_action( 'user_register', array(&$projectmanager, 'registerUser') );

    insert the line:
    add_action( 'wp_new_user_notification', array(&$projectmanager, 'registerUser', 10, 1 ) );

    Note: you only need to make this change if you allow users to register themselves for your blog, you’re using the profile_hook for projectmanager, and you want their profile dataset to be created automatically.

    My apologies, I pasted the wrong line in my last comment (something I had tried earlier that had not worked). The line that should be inserted is:

    add_action( 'get_user_meta', array(&$projectmanager, 'registerUser', 10, 1 ) );

    Or not… now dataset creation is happening intermittently, and I’m not sure if it’s connected with the changes I made or if it just showed up because I was registering a large enough number of test users.

    I think I’m out of my depth here… help?

    Ok, I was wrong… it was a permissions issue, sort of. The function addDataset in projectmanager/admin/admin.php was testing the capabilities of the current user to decide whether or not it would create a new dataset. Problem is, when user_register is run by a new user registering themselves on the site, there is no current user.

    I’ve gotten around this by adding a simple if statement around the sections of code (lines 671-683) that test the current user’s capabilities. The first and final lines are what I added:

    if ( is_user_logged_in() ) {
    		// Negative check on capability: user can't edit datasets
    		if ( !current_user_can('edit_datasets') && !current_user_can('projectmanager_user') && !current_user_can('import_datasets') ) {
    			$this->setMessage( __("You don't have permission to perform this task", 'projectmanager'), true );
    		// user has only cap 'projectmanager_user' but not 'edit_other_datasets' and 'edit_datasets'
    		if ( current_user_can('projectmanager_user') && !current_user_can('edit_other_datasets') && !current_user_can('edit_datasets') && !current_user_can('import_datasets') ) {
    			// and dataset with this user ID already exists
    			if ( $this->datasetExists($project_id, $user_id) ) {
    				$this->setMessage( __("You don't have permission to perform this task", 'projectmanager'), true );

    As is probably apparent at this point, I am not very good at this… I don’t claim much knowledge of php or coding wordpress plugins. I don’t know if this is the best way to fix the problem, or if it will introduce any other problems, including possible security issues. This was just the best way I could see of allowing new users to register themselves and have datasets created for them with this plugin. I’ve tested it a bit more thoroughly this time (a larger test size), and currently new datasets are being created 100% of the time. And you do not need the changes to projectmanager.php I previously recommended to make this work, it all happens through the user_register function already being called.

    Sorry for the earlier confusion, I really thought I had it fixed and I’m still not sure why it worked intermittently. Hopefully my trial and error on this (and my solution, if inelegant) will be useful to someone else.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: ProjectManager] User Dataset Not Created on New User Registration’ is closed to new replies.