ActionScheduler_DBStore::get_group_id()
Get a group's ID based on its name/slug.
Method of the class: ActionScheduler_DBStore{}
No Hooks.
Return
Int
. The group's ID, if it exists or is created, or 0 if it does not exist and is not created.
Usage
// protected - for code of main (parent) or child class $result = $this->get_group_id( $slug, $create_if_not_exists );
- $slug(string) (required)
- The string name of a group.
- $create_if_not_exists(true|false)
- Whether to create the group if it does not already exist. Default, true - create the group.
Default: true
ActionScheduler_DBStore::get_group_id() ActionScheduler DBStore::get group id code WC 7.3.0
protected function get_group_id( $slug, $create_if_not_exists = true ) { if ( empty( $slug ) ) { return 0; } /** @var \wpdb $wpdb */ global $wpdb; $group_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT group_id FROM {$wpdb->actionscheduler_groups} WHERE slug=%s", $slug ) ); if ( empty( $group_id ) && $create_if_not_exists ) { $group_id = $this->create_group( $slug ); } return $group_id; }