Skip to content

Instantly share code, notes, and snippets.

@stephenharris
Created January 23, 2013 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephenharris/4614225 to your computer and use it in GitHub Desktop.
Save stephenharris/4614225 to your computer and use it in GitHub Desktop.
Get membership level ID by Name / Slug
<?php
/**
* Get membership level ID by Name / Slug
*/
//Be careful - the name is not unique!
$level = wpmember_get_level_by( 'name', 'Basic Subscription' );
if( $level ){
$level_id = $level->term_id;
}else{
//Not found!
}
$level = wpmember_get_level_by( 'slug', 'basic-subscription' );
if( $level ){
$level_id = $level->term_id;
}else{
//Not found!
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment