I want to show a custom notification for a free user until they purchase the paid plan. Can I do that?

  • Yes, of course. How do you know if the user has a plan or not? Hopefully there's a function in whichever plugin you use for membership (which?). Where do you want the notification? You can probably edit it into the header or footer of your theme. – Rup Nov 21 at 21:01

Yes, if you will be doing that with code. You will have to - add a Role (like free user).

Add this code (change code as needed for your work).

function update_roles_free_user() {
   add_role( 'free_user', 'Free User', array( 'read' => true, 'level_0' => true ) );

add_action( 'init', 'update_roles_free_user' );

You can use the built-in WordPress function current_user_can.

if current_user_can('level_0'){
'do some stuff here'

or you can do it this way.

$user = wp_get_current_user();
$allowed_roles = 'free_user';
if ( array_intersect( $allowed_roles, $user->roles ) ) {
   // Do Stuff Here

Or you can use the over-the-counter plugin: https://wordpress.org/plugins/members/

Here are your reference notes:





| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.