Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter conkidd

    (@conkidd)

    Well, after much effort over the weekend I’ve found a way to ‘hack’ the plugin to make the import of custom user meta work as expected. Here is how I accomplished this using Job Title as an example…(please if an easier method exists please advise)..

    In plugin files:

    Step 1)
    configuration.php (line 83 – add_settings_section, we add the additional settings fields as follows)

    'onelogin_saml_attr_mapping_jobtitle' => __('Title', 'onelogin-saml-sso'),

    Step 2)
    configuration.php (line 285, include a function to register the setting)

    function plugin_setting_string_onelogin_saml_attr_mapping_jobtitle() {
    		echo '<input type="text" name="onelogin_saml_attr_mapping_jobtitle" id="onelogin_saml_attr_mapping_jobtitle"
    			  value= "'.get_option('onelogin_saml_attr_mapping_jobtitle').'" size="30">'.
    			  '<p class="description">'.__("Job Title?", 'onelogin-saml-sso').'</p>';
    	}

    Step 3)
    validate.php (line 87, $attr_mappings array we will add our setting)

    'onelogin_saml_attr_mapping_jobtitle' => __('Title', 'onelogin-saml-sso'),

    Step 4)
    functions.php (line 235 – we will add into the onelogin_saml_updateuser() function to update the current user meta when they login – note you must have this setting enabled in the plugin for this to work.

    $jobTitleMapping = get_option('onelogin_saml_attr_mapping_jobtitle');
    update_user_meta($user_id, 'user_job_title', $attrs[$jobTitleMapping][0]);

    Step 5)
    Go to the settings page and enter the attribute as it shows in the custom attribute in OneLogin Parameters. I added a custom parameter of JobTitle and entered ‘JobTitle’ into the new settings field in the plugin configuration.

    Step 6)
    I use piklist to create my user profile custom meta boxes but you could also use ACF or any other popular field plugin. Just make sure the field name matches the meta field you are trying to update in the update_user_meta function in step 4.

    Expected Result: When a user logs into the WordPress site from OneLogin

    —————————————————————————-
    Obviously in a perfect world the plugin would just have a hook that we could add this data into. The biggest issue I see remaining on my side is not being able to log in as a user or auto provision. Will keep working on that..

    Thread Starter conkidd

    (@conkidd)

    Also, why under SSO in the OneLogin app config can I not choose:

    ‘Allow assumed users to sign into this app’

    The option exists but will not allow the box to change to ‘true’. It reverts to unchecked after click.

    Thread Starter conkidd

    (@conkidd)

    Thanks macbookandrew – this appears to work! Appreciate your help here.

    Thread Starter conkidd

    (@conkidd)

    Dbrieck – i tried your fix but it does not correct the issue.

    jcrea – i don’t want to make changes to core for obvious reasons.

    glatze – any update or proper work around on your side?

    Thanks all.

    Thread Starter conkidd

    (@conkidd)

    Apologies on the above. I meant to disable the email string to be updated on disable user.

    Thread Starter conkidd

    (@conkidd)

    Another issue is that when I set a user to disabled, their email address is updated and sends them a notification that their email address has been updated.

    I tried to apply:

    add_filter( ‘send_password_change_email’, ‘__return_false’);

    However this does not solve that issue… Any advice?

    Thanks all

Viewing 6 replies - 1 through 6 (of 6 total)