Assign User Role on Subsite

Hello,

I'm wondering if it is possible to assign user a role on a sub-site?

Here's my setup. I'm running several sites (some single sites and some multisites). My main (master) site is a single install. On one of my subsites I'm running WPJobBoard plugin.

What I am trying to do is have one location (master site) where my Employer clients can login and control all of their profile info, password, etc. and one location to access the different tools/websites without having them register on each site individually.

The User Sync works great but I'm running into a problem with my job board site.

The users gets added to the job board site but they don't get added to the Job Board table as the role Employer.

I have contacted the plugin developer and they said that it should be possible to add a filter or hook when registering.

Hi,
if there is some filter or hook when registering an Employer you can register an entry in wp_wpjb_employer table for this user, using following code

$object = new Wpjb_Model_Company();
$object->user_id = $user_id;
$object->company_name = "";
$object->company_website = "";
$object->company_info = "";
$object->company_country = "";
$object->company_state = "";
$object->company_zip_code = "";
$object->company_location = "";
$object->is_public = 1;
$object->is_active = 1;
$object->is_verified = 1;
$object->save();

Is this possible with the User Sync plugin and if so could you point me in the right direction to get it working.

Master Site: e-core.ca
Sub-Site: jobs.e-core.ca

Thanks for the help,

Jay

  • Milan
    • WordPress Wizard

    Hello jayjay

    Hope you are well today and thanks for asking us. :slight_smile:

    I'll need our developer's advise on this. I've pinged him but he is not online currently. I will update you here about his insights once he gets online and update me. :slight_smile:

    Till that time, please let me know if you have something else to say or ask. :slight_smile:
    Cheers,
    Milan

  • Milan
    • WordPress Wizard

    Hey jayjay

    Hope you are well today and sorry for being late here.

    Yes I had talk over this with our developer and he confirmed that our plugin is supporting

    do_action( 'user_register', $user_id );

    filter. You can know more about that in this codex article, user_register

    That is the place where you can do can attach your custom coding for assigning new role to user. And if you want to be sure that user is being created by User Sync plugin then you can check it by ensuring $_REQUEST['user_sync_action'] variable's availability.

    So something like this would be helpful, ?

    add_action( 'user_register', 'wpmu_user_sync_register_handler' );
    function wpmu_user_sync_register_handler( $user_id ){
    	if( isset( $_REQUEST['user_sync_action'] ) ){
    		//Do your user role adding stuff here.... :)
    	}
    }

    Hope this helps you JayJay.
    Cheers,
    Milan

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.