Learndash change user role after completing the course

Got it fixed. Here is the code: add_action(‘wp_head’, function(){ if(is_user_logged_in()){ $user = wp_get_current_user(); if ( in_array( ‘pre_subscriber’, (array) $user->roles ) ) { $passed = learndash_user_quiz_has_completed($user->ID, 8731, 8388); if($passed){ // Remove role $user->remove_role( ‘pre_subscriber’ ); // Add role $user->add_role( ‘subscriber’ ); } } }} );

Restrict access to custom post type based on its taxonomy terms

You should be able to check the conditions and add capabilities like this: if(wp_get_current_user(‘gallerist’) AND ‘cats’ == get_post_type() AND has_term( ‘status’, ‘age’ )) { $gallerist_role = get_role( ‘gallerist’ ); // Adding a new capability to role $gallerist_role->add_cap( ‘custom_capability’ ); } I am sorry I can not test it but I think it is a start

if role is logged in then do something

Something like this would be more efficient. This is basic PHP by the way, not WP specific. function add_extra_item_to_nav_menu( $items, $args ) { $roles = [ ‘administrator’ => [ //Role – slug name ‘SCHOOL_NAME-A’, //url path – appended to the end ‘ADMIN’, // can be any name – appended to SHOP NOW button ], ‘ROLEABC’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)