What’s the correct way to add capabilites to user roles?

A third-party plugin adds the capability ‘edit_booked_appointments’. I’d like to assign this capability to the already existing user role ‘editor’. I created the following function in my child theme:

function add_booking_role_to_editor() {     $  role = get_role( 'editor' );      $  role->add_cap( 'edit_booked_appointments', true );  }  add_action( 'init', 'add_booking_role_to_editor'); 

As far as I understand the whole topic, user roles get written to the database so there is no need to hook this function into the ‘init’ action. What would be the correct way to do this? Is there a way to fire this once, after the corresponding plugin has been activated? I tried it with the action ‘plugins_loaded’ but that did not work at all.

DB Design – Assigning users to multiple sites with different roles

I am working on a DB design that lets me manage roles and permissions for each user per site. These are my business rules:

  • A user can manage multiple sites
  • A user can only have one role per site
  • A site can have multiple users

I already have two designs that I came up with, I just need validation which one would work better against my business rules.

First is using a ternary table site_user_role that consists of a relationship between site, user and role table. But this already breaks the rule of a user having only one role per site because those 3 primary keys would be unique and I can create a combination of two roles for a user within 1 site. Any complications with this design?

enter image description here

The second idea is having two binary tables. The site_user and site_user_role table. This arrangement I am quite sure I will not duplicate a role for a user on a site. But Is it weird to have a primary key aside from the Foreign keys on the site_user binary table? Any complications with this design?

enter image description here

How to resolve fundamental differences in perspective between players and DM about the roles each has in decision making?

To give context: I am a DM running a D&D 5e campaign set in a home-brew setting for the better part of a year. A few months ago I suggested having an alternate “gaiden” style campaign set in the same setting in which the same set of characters go on short adventures with rotating DMs that could be used during sessions where some players were not available to play. During this winter holiday, one of my players was unable to make sessions and I implemented this system with myself taking the first turn as DM. All players were given invitations to the campaign and given character sheets on our role play app, including the non-available player. The adventure was expanded as the players came to enjoy the narrative and I had new ideas, and is now reaching towards its conclusion. My absent player recently became available again and expressed interest in joining in this campaign. I said yes, some members of the group said no.

While the exact argument was long and circuitous with some hurt feelings, the basic salient points from each side were:

Against Joining

  • Inclusion of new members of the campaign are group decisions.
  • Introducing new characters towards the end of the campaign disrupts the narrative.
  • By making an executive decision under DM purview from the get go, I am undermining their perspectives and feelings by “laying down the law” and not listening to their side. (This might be true.)

For Joining

  • The player is part of the pre-existing group and is not a new member as this adventure is an extension of main campaign.
  • While players are encouraged to add to the narrative, what is and is not narrative appropriate falls under the domain of the DM as stated on pages 5 & 6 of the 5e Players Handbook.
  • Additionally, I have interesting narrative plans involved with his character, that several players and DM’s outside of this group approve of.
  • As the DM, I serve as referee. As I view this player as a pre-existing group member, it comes under my purview to make judgement calls how certain player on player issues are resolved. This has been the case before when other players had issues with class abilities overlapping over each others roles and could not come to a compromise, and certain players having issue with role-play issues overshadowing other players. In both cases I had to make official DM statements to resolve the issue.
  • As a DM I have a prerogative to enjoy myself during these sessions else I lose interest in the game and it dies. Excluding a player who I see as part of the group who has done nothing wrong do to what I feel is pressure from a large minority of players does not sit right with me and would impede in my enjoyment.

In the end, I said that I will not exclude anyone member of the group at the behest of the others for what I see as a non-issue, and several player were upset with this decision, seeing it as inappropriate, with at least one player leaving the group outright.

So how do I this resolve fundamental differences in perspective between players and DM about the roles each has in decision making? Am I in the right for making the decision I did? If so, how do I resolve this group dynamic issue? If not, how do I repair these ingresses?

SQL User Query by Multiple Roles using PHP

I can successfully get all my WordPress users using the following code:

global $  wpdb; $  sql = 'SELECT * FROM ' . $  wpdb->users; $  users = $  wpdb->get_results( $  sql, 'ARRAY_A' ); 

However, I need to filter the users with multiple roles (only get “role1” and “role2”). I have tried various methods including the following which does not work:

global $  wpdb; $  sql = '     SELECT ID, display_name FROM wp_users      INNER JOIN wp_usermeta ON ( wp_users.ID = wp_usermeta.user_id )       INNER JOIN wp_usermeta AS mt1 ON ( wp_users.ID = mt1.user_id )      WHERE 1=1      AND (        (          (            ( mt1.meta_key = 'wp_capabilities' AND mt1.meta_value LIKE '%role1%' )         )          AND          (            (              ( mt1.meta_key = 'wp_capabilities' AND mt1.meta_value LIKE '%role2%' )           )         )       )     )      ORDER BY user_login ASC     '; $  users = $  wpdb->get_results( $  sql, 'ARRAY_A' ); 

Is Customer Service Agent and the Customer two different personas or different roles?

Are ‘Personas’ and ‘Roles’ different in every scenario?

Although i did my reading about roles and personas, im a bit confused about this topic with the context i’m working on.

Scenario – One day Bruce(Customer) finds out his water heater is broken and calls XYZ company to get it fixed. John(Customer service agent) receives the call and assigns Bob(Technician) for to install a water heater.

John, Bruce and Bob are these 3 personas? or are they considered as 3 different user roles who interact with XYZ service?

What to add to attack roles

I’m a little uncertain what to add to my attack roles. Can anyone confirm which of the below highlighted modifiers I should be adding to my D20 role for attack with longbow? I am proficient in archery. Do I add all three or just some?

Character stats

Thanks in advance, Mick