Skip to:
Content
Pages
Categories
Search
Top
Bottom

Different profile types and different user roles – Part II

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

  • 1a-spielwiese
    Participant

    @1a-spielwiese

    @ section 5th, part c):

    'I guess it’s, because the “fan-question” requires as well an answer; but it is not answered, because that member is a team (not a fan).'

    It’s in deed that: When I change the (first) “fan-question” from ‘required’ into ‘not required’ it’s possible to save the answer of kampfsportlerinnenneuwied regarding the team question, and it is displayed correctly in the frontend:

    http://1a-spielwiese.de/wp-content/uploads/2014/09/kampfsportlerinnen_answer.jpg

    But I don’t want to change the “fan-question” from ‘required’ into ‘not required’.

    —-

    PS.:

    The text of the second “fan-question” was still not displayed; and the text of the 5th question (‘Ergänzende Hinweise zu Deinem Geschlecht’) of the ‘base group’ wasn’t displayed as well:

    http://1a-spielwiese.de/wp-content/uploads/2014/09/text_missing.jpg

    It was because I deactivated (by chance) ‘Buddypress xProfile Rich Text Field’-Plugin. Reactivating it, both profile fields get displayed again.


    1a-spielwiese
    Participant

    @1a-spielwiese

    En passant: Is there any way for truly renaming the user roles from ‘contributor’ to ‘team’ and from ‘subscriber’ to ‘fan’, sothat I could keep the ‘Label’ simple (i.e.: without explaining: ‘Choose as Team: Contributor; and as Fan: Subscriber’)?

    Whether renaming, I still don’t know. But with ‘Capability Manager Enhanced’-plugin I could create entirely new user roles ‘team’ and ‘fan’ – and with ‘WP Roles at Registration’-plugin i could place them on the registration page:

    http://1a-spielwiese.de/wp-content/uploads/2014/09/Reg_Form_with_User_Roles.jpg

    But a problem remains: How can I make ‘Subscriber’ not being the standard user role anymore?

    >But a problem remains: How can I make ‘Subscriber’ not being the standard user role anymore?

    That is a wp setting – settings>general ‘New User Default Role’ You should be able to select any new role created from the dropdown.


    1a-spielwiese
    Participant

    @1a-spielwiese

    @Hugo:

    That is a wp setting – settings>general ‘New User Default Role’ You should be able to select any new role created from the dropdown.

    It seems, that is only a WP SingleSite feature. I can’t find it within the WP general settings of my MultiSite installation – neither on the network level, nor on the root-blog level.

    Good point – doesn’t exist, MS is a law unto it’s self.

    You may need to write a function hooked to the registration process that changes the user role then.


    1a-spielwiese
    Participant

    @1a-spielwiese

    Follow-up:

    7th:

    Capability Manager Enhanced to define custom user roles, if you’re not satisfied with the default wordpress roles (subscriber, contributor,…).
    The first step is to create your user roles

    https://buddypress.org/support/topic/resolved-different-profile-types-and-different-user-roles/

    As ready implied there: I did this – and it works so far.

    8th:

    Create a xprofile field (selectbox) with the title “User Role” and name the options “Band Role” and “Fan Role” – in my case. You can call them whatever you want. Place this field in the “base” profile group, otherwise it won’t be shown during registration. Also make the field “required”. In my case the user can’t decide, if the visibility of the field can be changed.

    I did it already, when I installed and activated ‘BP Profile Search’-plugin – and it works.

    However, to choosed a dropdown menu and the categories ‘team’ and ‘fan’.

    9th:

    I modified:

    ?php
    function custom_bp_core_signup_user($user_id) {
        $user_role = strtolower(xprofile_get_field_data('User Role', $user_id));
        switch($user_role) {
            case "Band Role":
                $new_role = 'band';
                break;
            case "Fan Role":
                $new_role = 'fan';
                break;
        }
        wp_update_user(array(
            'ID' => $user_id,
            'role' => $new_role
        ));
    }
    add_action( 'bp_core_signup_user', 'custom_bp_core_signup_user', 10, 1);

    into:

    function custom_bp_core_signup_user($user_id) {
        $user_role = strtolower(xprofile_get_field_data('Mitglieder-Kategorie (Team oder Fan?)', $user_id));
        switch($user_role) {
            case "Team":
                $new_role = team';
                break;
            case "Fan":
                $new_role = 'fan';
                break;
        }
        wp_update_user(array(
            'ID' => $user_id,
            'role' => $new_role
        ));
    }
    add_action( 'bp_core_signup_user', 'custom_bp_core_signup_user', 10, 1);

    (I omitted <?php, because I created not a new bp-costum.php, rather inserted the code into my yet existing bp-costum.php. I inserted the modified code above the line ?>.)

    I did not understand, which effect this insertion should have – but, however, – as far as I see – it causes no harm.

    Did anyone understood, for which purpose the above mentioned code is?

    10th:

    I inserted as well:

    //hide the user role select field in edit-screen to prevent changes after registration
    add_filter("xprofile_group_fields","bpdev_filter_profile_fields_by_usertype",10,2);
    function bpdev_filter_profile_fields_by_usertype($fields,$group_id){
    
    //only disable these fields on edit page
    if(!bp_is_profile_edit())
    return $fields;
    //please change it with the name of fields you don't want to allow editing
    $field_to_remove=array("User Role");
    $count=count($fields);
    $flds=array();
    for($i=0;$i<$count;$i++){
    if(in_array($fields[$i]->name,$field_to_remove))
    unset($fields[$i]);
    else
    $flds[]=$fields[$i];//doh, I did not remember a way to reset the index, so creating a new array
    }
    return $flds;
    }

    into my bp-costum.php – again above the line ?>.

    It does not work:

    — threre the user role is still changeable:

    http://kampfsportlerinnenneuwied.1a-spielwiese.de/wp-content/uploads/sites/2/2014/09/user_role_still_changeble.jpg

    http://1a-spielwiese.de/members/kampfsportlerinnenneuwied/profile/edit/group/1 causes an redirection error. – The redirection error disappears, when I’m not logged in as kampfsportlerinnenneuwied, rather as superadmin.


    1a-spielwiese
    Participant

    @1a-spielwiese

    So, the following questions remain:

    A. How can I make profile fields, which are asigned only to one member category / user role, ‘required’? Cfr. above.

    B. Anyone knows, whether there is a function already written, which allows to change or delete the standard user role in WP MultiSite?

    C. What is the purpose of the penultimate step of the instructions of @noizeburger? – What have I to check for seeing, whether it works or not?

    D. Why does the last step of the instructions of @noizeburger do not work for me? How can I make the member category / user role unchangeable for my members?

    @amalsh / @jonaro / @lebearuk / @kamillamonkey and @jeffacubed:

    Do you have any idea regarding this issues?


    1a-spielwiese
    Participant

    @1a-spielwiese

    @ D.:

    I guess, the mistake was, that I – after creating the new user roles ‘Team’ and ‘Fan’ – forgot to asign my already existing members to that categories. But, however, when I try it now, then I can’t:

    http://1a-spielwiese.de/wp-content/uploads/2014/09/changing_user_role.jpg

    However, as alreday mentioned: On the registration page the new user roles are displayed:

    http://1a-spielwiese.de/wp-content/uploads/2014/09/Reg_Form_with_User_Roles.jpg


    1a-spielwiese
    Participant

    @1a-spielwiese

    Further update:

    To the users of the root blog I can asign the new user roles ‘Team’ and ‘Fan’; but I can’t neither on the network level (there isn’t any change of user’s role possible) nor on the subdomain-blog level (there are the roles only: administrator, editor, author, contributor, subscriber).

    • On the root-blog level there is within the admin panel a section users/capabilities.
    • On the subdomain-blog level there is not within the admin panel a section users/capabilities.

    1a-spielwiese
    Participant

    @1a-spielwiese

    My mistake:

    On the subdomain-blog level there is not within the admin panel a section users/capabilities.

    There are such sections. I assume, I had overlooked them before simply (- though I made in the meantime one of the subdomain-blog users to a root-blog user as well. But I guess not, that this could made thoses sections visible for me.)

    So, now I can change the user role of the subdomain-blog users.

    Persisting problem:

    The xProfile field is still changeable for them:

    http://kampfsportlerinnenneuwied.1a-spielwiese.de/wp-content/uploads/sites/2/2014/09/user_role_still_changeble.jpg


    1a-spielwiese
    Participant

    @1a-spielwiese

    @hnla / https://buddypress.org/support/topic/different-profile-types-and-different-user-roles-part-ii/#post-201146:

    By chance I found the solution regarding the ‘default user role’-issue:

    Within the wp-admin-folder there is not only an options-general.php, rather as well an options.php.

    Within the comment at the beginning of this file is written: ‘If accessed directly in a browser this page shows a list of all saved options along with editable fields for their values.’

    Therefore I adressed this file with 1a-spielwiese/wp-admin/options.php – and there I found the opportunity to change the default user role:

    http://1a-spielwiese.de/wp-content/uploads/2014/10/wp-admin-options-php.jpg

    After changing it into ‘fan’ (note: it’s not possible to leave the line blank!), on the page options-general.php?page=wp-roles-at-registration it is now possible to select only the roles ‘fan’ and ‘team’:

    http://1a-spielwiese.de/wp-content/uploads/2014/10/rar-settings_without_subscriber.jpg

    And after saving it, ‘subscriber’ disappears from the registration page as well:

    http://1a-spielwiese.de/wp-content/uploads/2014/10/register-page_without_subscriber.jpg

    —-

    However, these other above mentioned problems:

    A. How can I make profile fields, which are asigned only to one member category / user role, ‘required’? Cfr. above.

    C. What is the purpose of the penultimate step of the instructions of @noizeburger? – What have I to check for seeing, whether it works or not?

    and

    D. Why does the last step of the instructions of @noizeburger do not work for me? How can I make the member category / user role unchangeable for my members?

    @amalsh / @jonaro / @lebearuk / @kamillamonkey and @jeffacubed:

    Do you have any idea regarding this issues?

    – cfr. regarding D.: http://kampfsportlerinnenneuwied.1a-spielwiese.de/wp-content/uploads/sites/2/2014/09/user_role_still_changeble.jpg

    are still unresolved.


    1a-spielwiese
    Participant

    @1a-spielwiese

    The problems are still unresolved:

    ++ Cfr. regarding problem A. (Making xProfile fields required only for members with a certain user role):

    https://wordpress.org/support/topic/making-bp-xprofile-fields-required-for-certain-user (posted today)

    ++ Hide theses xProfile fields for members with other user roles:

    https://wordpress.org/support/topic/bb-xprofiles-acl-does-not-work (posted one week ago)

    ++ Cfr. regarding problem D. (Making answers unchangeable):

    https://buddypress.org/support/topic/how-to-make-some-xprofile-field-to-uneditable/#post-206808 (posted two days ago).

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Different profile types and different user roles – Part II’ is closed to new replies.
Skip to toolbar