Support » Plugin: Swim Team » ISSUE with ADMIN.PHP

  • Resolved gdisalvo

    (@gdisalvo)


    Hi Mike,

    I created a new ROLE = swimteam
    Added the capability author

    When check it on simple plugin or templates works fine.

    When I check the user meta – its there as

    a:1:{s:8:”swimteam”;b:1;}

    When they access swim team from main menu and use

    http://********/wp-admin/admin.php?page=swimteam.php

    I get

    You do not have sufficient permissions to access this page.

    Is there something your are checking in ADMIN to allow subscribers into Swimteam? I am trying to hide TABs in the user menu if they are nt in the new role.

    Can you assist?

    http://wordpress.org/plugins/wp-swimteam/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mike Walsh

    (@mpwalsh8)

    Can you see if it works correctly if you use “Editor”
    Instead of “Author”? If it does, I think I know why.

    Mike,

    No Luck Editor does same.

    Looks like I will try to remove the new role for now unless you know where I can tweak it?

    Plugin Author Mike Walsh

    (@mpwalsh8)

    I’ll have to look at the code and see. I know I check for Editor capability for the Manage and Report menus and Admin capability for the Options menu but the SwimTeam menu should be available to any subscriber but I don’t recall an explicit check for anything special.

    Hi Mike,

    I changed the role back to subscribe. At the bottom was capabilities “swimteam”

    In the meta for the user – I had both.

    And that seems to work – I will run a few more test.

    Apparently, when adding role and trying to use a template like get role prior to assigning the swimteam role, it doesn’t work in tandem.

    I will write back to see what else is going on as this could be a word press feature hidden.

    Hi Mike,

    Here is the answer. Apparently, without the subscriber role you cannot enter swimteam from frontend. The new role is to be used to distinguish that they are more than subscribe and less than author editor and admin. New custom role swimteam.

    In the theme function.

    function swimteam_addroles() {
    global $wp_roles;
    $role = get_role(‘swimteam’);
    $wp_roles->remove_role( ‘swimteam’ );
    ///// Just in case add the role for new changes in user admin
    $wp_roles->add_role( ‘swimteam’, ‘Swim Team’, array(‘swimteam’) );
    }
    add_action( ‘init’, ‘swimteam_addroles’ );

    function swimteam_addcaps() {
    global $current_user;
    ///// Check for non admin users and if they have been assigned swimteam
    if ( !current_user_can(‘manage_options’) && current_user_can( ‘swimteam’ ) ) {
    get_currentuserinfo();
    $user = wp_get_current_user();
    $userid = $user->ID;
    $roles = $user->roles;
    $role = array_shift($roles);
    ///// If they have swimteam change or add capabilties to their user
    ///// This gets them Reporting and extra swimteam TABs for viewing rosters and emails
    switch($role) {
    case (‘swimteam’):
    $user->add_cap(‘subscriber’);
    $user->add_cap(‘swimteam’);
    break;
    default:
    break;
    }

    }
    }
    add_action( ‘init’, ‘swimteam_addcaps’, 10, 0 );

    //////
    And in the swimteam user menu I check user can do swimteam role than allow TAB to be made and visible.

    In case you can use this in your future.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘ISSUE with ADMIN.PHP’ is closed to new replies.