• Hello, I really like your plugin but sadly I have been stuck.

    Can you please clarify the adding of a custom Type?

    I tried to add the roles from “wpjobster_user_type” to your plugin by changing $wp_roles to it but it only broke the plugin.

    Where do I add this variable in the code below?

    Thanks a lot

    /*
    * Add custom roles to Nav Menu Roles menu list
    * param: $roles an array of all available roles, by default is global $wp_roles
    * return: array
    */
    function kia_new_roles( $roles ){
    $roles[‘new-role-key’] = ‘new-role’;
    return $roles;
    }
    add_filter( ‘nav_menu_roles’, ‘kia_new_roles’ );

Viewing 1 replies (of 1 total)
  • Plugin Author HelgaTheViking

    (@helgatheviking)

    If you incorrectly manipulate the global $wp_roles then that makes sense you’d break things.

    re-posting the code snippet with a little clarification:

    `
    /*
    * Add custom roles to Nav Menu Roles menu list
    * param: $roles an array of all available roles, by default is global $wp_roles
    * return: array
    */
    function kia_new_roles( $roles ){
    $roles[‘new-role-key’] = ‘New Role Label’;
    return $roles;
    }
    add_filter( ‘nav_menu_roles’, ‘kia_new_roles’ );
    `

    the “new-role-key” is a bit of data that you will use later to know which “role” to test against. The “New Role Label” is just the part that displays in the menu item options.

    Take a look at these two examples:
    https://github.com/helgatheviking/nav-menu-roles-woocommerce-memberships
    https://github.com/helgatheviking/nav-menu-roles-wishlists-memberships

    They are pretty similar and you should only need to edit the last 3 helper functions to make them specific to your plugin.

    If you can provide answers to:

    1. a way to get an array of all “roles”
    2. A way to test if current user has a specific “role”

    From the Job plugin.. or in their documentation… I could create the integration for $175. If you need me to figure it out on my own, I’d charge $300.

    I’ll also need a link to a copy of the Jobs plugin for testing. Contact me at kathyisawesome.com/contact if you’re interested.

Viewing 1 replies (of 1 total)

The topic ‘Adding new roles to Plugin’ is closed to new replies.