• Resolved strongandathletic

    (@strongandathletic)


    Good afternoon,

    Me and another forum member, after hassling a little bit with the client portal plugin trying to make certain functionalities work we stumbled over the following problems:

    1. Client portal redirection PHP function works well with the classic editor, once Gutenberg is activated via the modification of Client portal’s PHP code by adding the line ” ‘show_in_rest’=> true, “, initially the redirection PHP function works well but once the content of a given user’s private page is updated by adding content to it, the named function does not redirect very well.

    2. Once the shortcode [client-portal] is added internally into a page in WP, this page won’t be opened to be edited, instead, it redirects automatically to the portal page. While it is supposed to re-direct at least an Admin should be able to open the page for editing what is inside.

    3. One of the functions uses the break' instruction to get out of afor’ loop. I doubt this is highly suggested in programming circles, instead, a loop control via the use of a boolean value and a conditional `if’ is commonly suggested.

    In relation to the first problem, this is just a hypothesis, so there could be a different reason for why the redirection of the user to his/her private page does not work. It could be that Gutenberg creates different sub IDs of the same page that is updated?? Therefore, the get_private_page_ID_link can’t get the right ID??? I don’t know yet, but this is a very important problem that requires immediate attention because the line code that was suggested by a member of the forum to activate Gutenberg, also activate other plugins. I don’t think that an admin can do much with just the classic editor considering all the functionalities offered on the web which can be accessed with the aforementioned line of code.

    Thank you for your attention and any suggestions would be greatly appreciated.

    Regards.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi there,

    Thanks for the detailed report!

    If modifying our plugin in this way is causing problems, then the recommended course of action is to revert the modification.

    All that I can do is bump up by a notch our feature request for the Gutenberg editor in Client Portal.

    And hopefully the development team can get to it at some point. I will add, though, that they have quite a lot on their table at the moment, so I can’t promise that it will happen in the recent future.

    With the best of wishes,
    Gabriel

    Hello again,

    I have seen now that 2) happens even without any modifications so I am issuing a bug report for this.

    Until it’s fixed, the only way around it when you want to edit such a page is unfortunately to briefly disable the Client Portal plugin.

    Sorry for not understanding this initially.

    Best regards,
    Gabriel

    Thread Starter strongandathletic

    (@strongandathletic)

    Greetings @gabrielberzescu,

    I think I probably found the root of the issue in the case of the activation of the Gutenberg.

    I tested the following function:

    function cp_shortcode( $atts ){
    if( !is_user_logged_in() ){
    if( !empty( $this->options[‘portal-log-in-message’] ) )
    $message = $this->options[‘portal-log-in-message’];
    else
    $message = $this->defaults[‘portal-log-in-message’];

    return $message;
    }
    else{
    $user_id = get_current_user_id();
    /* echo $user_id; */
    $private_page_id = $this->cp_get_private_page_for_user( $user_id );
    /* echo $private_page_id; */
    if( $private_page_id ) {
    $private_page_link = get_permalink($private_page_id);
    ?>
    <script>
    window.location.replace(“<?php echo $private_page_link ?>”);
    </script>
    <?php
    }/*else{

    echo $private_page_id;
    }*/
    }
    }

    This function works fine but I suspeched that the issue might be coming from the function cp_get_private_page_for_user:

    function cp_get_private_page_for_user( $user_id ){
    $args = array(
    ‘author’ => $user_id,
    /*’post_status’ => ‘publish’,’inherit’,*/
    ‘posts_per_page’ => 1,
    ‘post_type’ => ‘private-page’,
    );
    print_r($args);
    /* echo $user_id; */
    /* echo get_posts($args); */
    /* print_r(get_posts( $args )); */
    $users_private_pages = get_posts( $args );
    /* echo $users_private_pages; */
    if( !empty( $users_private_pages ) ){
    foreach( $users_private_pages as $users_private_page ){
    return $users_private_page->ID;
    break;
    }
    }/* else {echo “potato”; } */
    /* we don’t have a page */
    return false;
    }

    It turns out that this is true and the issue stems from get_posts( $args ). In the case that Gutenberg is active and the content is updated using Gutenberg this function returns an empty array!! Therefore, there is no permalink to get.

    I searched online and the issue appears to be related to the number and type of arguments that are passed to the get_posts function. Given this function do you have any suggestions about any arguments that should be added or removed? I tried a few one but still not working.

    Anyway, I hope this help. Have a wonderful evening.

    Regards.

    Hello there @strongandathletic

    This is about:

    1. Client portal redirection PHP function works well with the classic editor, once Gutenberg is activated via the modification of Client portal’s PHP code by adding the line ” ‘show_in_rest’=> true, “, initially the redirection PHP function works well but once the content of a given user’s private page is updated by adding content to it, the named function does not redirect very well.

    Correct?

    If so, then I can forward this information to the development team for when they add support for Gutenberg in the private pages.

    Best of wishes,
    Gabriel

    Thread Starter strongandathletic

    (@strongandathletic)

    Hello @gabrielberzescu,

    That’s totally correct. With my previous post, I was pointing at what might be potentially the problem when adding the line o‘show_in_rest’=> true. It appears that the problem stems from the get_posts function.

    Regards.

    All right, thank you! ??

    I am forwarding the information to our development team.

    Cheers,
    Gabriel

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Problems with Client portal’ is closed to new replies.