Embed Snippet on Your Site
MemberPress: Update Account Course Tab Link With User-Role-Based Custom URLs
This code snippet replaces the default URL of the "Courses" tab link in the navigation menu on the MemberPress Account page with the user-role-based custom URLs.
The sample code below sets the conditions for the Administrator user role.
Here, if the user is an Administrator, the Course tab URL will be linked to the page with the /admin-courses/ slug.
For all other user roles, the Course tab URL will be linked to the page with the /user-courses/ slug.
The condition user role can be changed by replacing the administrator user role with the desired user role on this line:
if (current_user_can('administrator')) {
The Courses tab link URL used when a user matches the condition can be adjusted by replacing the /admin-courses/ slug with the needed custom page slug / URL, on this line:
return '/admin-courses/';
The URL user for all other users (who don’t match the condition) can be adjusted by replacing the /user-courses/ slug with the needed custom page slug / URL on this line:
return '/user-courses/';
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Comments