• Hi,

    Could you possibly add an example to the description tab that uses regular expression.

    Ie. Show menu item to user roles containing the number “4” or roles that contain the letter “y”

    Is it even possible?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author shazdeh

    (@shazdeh)

    That is possible, although a bit tricky, as sometimes the user has multiple roles so you have to watch for that. You could do something along the lines of:

    
    preg_match( '/4/', join( '|', $GLOBALS['current_user']->roles ) )
    

    What comes between // is the Regex, that will check if any of the user roles contains the number 4.

    Thread Starter newbie0117

    (@newbie0117)

    What about primary role only?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Php Regex Example’ is closed to new replies.