• Resolved Jacob Hill

    (@tekfused)


    Hello,

    I’m trying to use a Pods settings page to do a number of things which includes populating a user’s role using WP CLI.

    I almost have it working, but the problem is that the the [user role] relationship field returns the role’s ID, rather than the display name… The WP CLI commands [wp user set-role] and [wp user add-role] require the string (ie administrator), you cannot query against the role ID… Kind of bizarre.

    I’ve looked at the functions that WP makes available, and it is the same situation:

    https://codex.www.ads-software.com/Function_Reference/get_role

    The get_role function requires the name of the role, and querying against the ID returns no result.

    FYI, I’m using the [pods_api_post_save_pod_item] action and this PHP command in my functions.php file to retrieve the data:

    $role_elevated = escapeshellarg($pieces[ ‘fields’ ][ ‘access_role_elevated’ ][ ‘value’ ]);

    I then pass this and other variables into a bash shell script that executes WP CLI commands among other commands.

    A work around I’m thinking of is simply defining my own custom defined list of roles. I was hoping I could take advantage of the automation offered by the relationship field though.

    Appreciate any feedback that you can provide. Thanks!

    Jake

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘User Role Relationship Field Returns Role ID’ is closed to new replies.