• Resolved Tobias

    (@oneside)


    Hi, the plugin does not seem to work with the Breakdance Page Builder. As soon as you design a page with the builder, the roles set for the page “Limit access to the content to users of the selected roles.” take no longer apply and the user will see the content whether he has access or not. Perhaps this is due to the possibility of running breakdance websites without a theme.

    Nevertheless, I would like to use the plugin. To do this, I could use PHP in the Breakdance Editor to query whether access rights have been set for the user group of the user under “Content Permissions” on the specific page. Is there a PHP function of the members plugin with returns true/false if the current user has access to the current content set for the page under “Content Permissions > Limit access to the content to users of the selected roles.”

    Then I could use this query to check in the Breakdance builder whether the user has access or not and redirect if needed.

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

    (@jarekk)

    Hi @oneside

    You can use this code and adjust it:

    // Get current user's roles
    $user = wp_get_current_user();
    $user_roles = (array) $user->roles;

    // Get roles assigned to page/post with ID - 123
    $post_id = 123;
    $page_roles = members_get_post_roles( $post_id );

    // Set page as protected
    $protected_page = true;

    foreach($page_roles as $page_role) {
    // Set page as not protected if user has role assigned to Content Permissions
    if( in_array( $page_role, $user_roles ) ) {
    $protected_page = false;
    break;
    }
    }

    if(! $protected_page) {
    // Page is not protected for current user
    }

    I hope that helps.

    Thread Starter Tobias

    (@oneside)

    Works perfect. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.