• Resolved Sheryar Khan

    (@thesheryar)


    How can I assign a phpBB group when the user has a specific role.

    Goal: My goal is when a user has a Role ‘A’ on WordPress they should be on Group ‘A’ in phpBB

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author axew3

    (@axewww)

    Hello! looking for a test so to see an easy way to integrate, but at moment, unfortunately, when on editing a WP page and setting it, adding a membership so to make it viewable only when one of two possible, a free and a pay membership are subscribed, it return me the problem that the membership is not saved at all when i save/update the page… Looking ….

    the console return

    Object { code: "rest_forbidden", message: "Sorry, you are not allowed to do that.", data: {…} }
    index.js:1:763
    fetchRestrictedLevels Ember

    • This reply was modified 9 months, 1 week ago by axew3.
    Plugin Author axew3

    (@axewww)

    And unfortunately, it at moment return the same, even setting up the wordpress as http (so i hoped it would work fine, since the 403 error). But it still keep returning error on console as above said, even when on the membership plugin i’ve set the Force SSL option to NO and wp run on http.

    Plugin Author axew3

    (@axewww)

    I’ve find out after that the error was coming out due to woocommerce active; it cause also the subsequent error on Paid Memberships Pro about Rest request returning 403, when on edit page/post:

    GET
    https://localhost/wp/wp-content/plugins/woocommerce/assets/client/blocks/coming-soon.css?ver=wc-8.9.3
    [HTTP/1.1 404 Not Found 1104ms]

    then

    XHRGET
    https://localhost/wp/wp-json/pmpro/v1/post_restrictions/?post_id=2&_locale=user
    [HTTP/1.1 403 Forbidden 1052ms]

    then

    Object { code: "rest_forbidden", message: "Sorry, you are not allowed to do that.", data: {…} }
    index.js:1:763

    that is the issue above reported. Once woocommerce has been disabled Paid Memberships Pro work fine now.

    I will check as possible for an easy suggestion for you (except the already existent):

    https://www.axew3.com/w3/2022/12/phpbb-wordpress-roles-groups-switch/

    • This reply was modified 9 months, 1 week ago by axew3.
    Plugin Author axew3

    (@axewww)

    I just have take a look into the documentation and it is quite easy to assert that the Paid Memberships Pro plugin works very well and the documentation is very helpful and quite extended. WoW!

    Here there is an example that can be easily used exactly for the scope you say (with some modification and code addition so to connect to phpBB and so to change user’s groups based on results of these hooks):

    https://www.paidmembershipspro.com/hook/pmpro_after_all_membership_level_changes/

    OR THIS

    https://www.paidmembershipspro.com/hook/pmpro_after_change_membership_level/

    I will follow as i can to focus on a practical and very easy example.

    • This reply was modified 9 months, 1 week ago by axew3.
    Thread Starter Sheryar Khan

    (@thesheryar)

    Thank you axew3, I will give it a try ??

    Plugin Author axew3

    (@axewww)

    Hint (maybe stupid to say) for you (i will follow with this as possible):

    declare as global, vars

    $w3all_phpbb_connection and $w3all_config within the function you’ll create.

    Get the WP userdata into the function by ID, if the user email value is not already available.

    Then perform into phpBB a query to get the phpBB user id of this user, based on his email (or execute a little more complex but single query, to update values and switch the user from a group to another into phpBB).

    Or perform update/delete queries by user id after that you’ve get the ID, so to switch the user from a group to another into phpBB.

    Some queries examples are here (and some phpBB groups how to switch mechanism)

    https://www.axew3.com/w3/2022/12/phpbb-wordpress-roles-groups-switch/

    pss i’ve see the site you built. Awesome! ??

    • This reply was modified 9 months ago by axew3.
    • This reply was modified 9 months ago by axew3.
    • This reply was modified 9 months ago by axew3.
    • This reply was modified 9 months ago by axew3.
    Plugin Author axew3

    (@axewww)

    Another hint for you (since i was looking), and to be used outside of the indicated hooks:

    on any hook, to get user’s levels:

    $user_levels = pmpro_getMembershipLevelsForUser($uid,true); // passing the second param true, will get all levels, omitting it or passing it as false only the active one
    echo'<pre>';print_r($user_levels);exit;

    to get subscriptions, whenever for more ocmplex things needed:

    $active_subscriptions = PMPro_Subscription::get_subscriptions_for_user( $uid ); print_r($active_subscriptions);exit;

    of course, the same could be easily achieved with direct queries, once you see the database structure and you understand which data you want to do what.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Assign phpBB Groups according to WordPress Role’ is closed to new replies.