• Resolved projecta

    (@projecta)


    Endpoint is redirecting to the homepage. We have an app that needs to reach?https://guildedesfromagers.us/wp-json/wp/v2/pages?in order to show?https://guildedesfromagers.us/app/member-directory/?within the app, but UM is redirecting it. Is this required functionality or is there a way to disable this redirect?

    All other API endpoints are working properly with the Ultimate Member v2.6.10 plugin enabled, such as:

    https://guildedesfromagers.us/wp-json/wp/v2/posts
    https://guildedesfromagers.us/wp-json/wp/v2/types/post
    https://guildedesfromagers.us/wp-json/wp/v2/media
    https://guildedesfromagers.us/wp-json/wp/v2/categories
    https://guildedesfromagers.us/wp-json/wp/v2/taxonomies
    https://guildedesfromagers.us/wp-json/wp/v2/tags
    • This topic was modified 1 year, 3 months ago by Jan Dembowski.
    • This topic was modified 1 year, 3 months ago by Jan Dembowski. Reason: Formatting

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support yuriinalivaiko

    (@yuriinalivaiko)

    Hello @projecta

    The /wp-json/wp/v2/pages endpoint should not redirect to the homepage. I have just tested this endpoint on my site. This endpoint returns a collection of pages in JSON format.

    Could you investigate this redirect on your site to get details? You need to enable debug logging and add this code to the functions.php file. Once the code is added you’ll see detailed information about redirects in the debug.log file.

    Regards

    Thread Starter projecta

    (@projecta)

    Hi, this is what we are seeing:

    After enabling Debug & Debug Logging in the /wp-config.php and adding the provided code to the theme’s /functions.php we got the following debug trace for the 302 redirect when requesting https://guildedesfromagers.us/wp-json/wp/v2/pages/ (Note, the only plugin code that was called was for /plugins/Ultimate-Member/. All other files were WP Core files, which eliminates that it may be a conflict with another plugin.)
    
    [22-Aug-2023 21:51:54 UTC] Investigate redirect:
    
    Request:
    
    REMOTE_ADDR: 66.241.70.11
    
    REQUEST_URI: /wp-json/wp/v2/pages
    
    Location: https://guildedesfromagers.us
    
    Status: 302
    
    Debug Backtrace:
    
    public_html/wp-includes/class-wp-hook.php line 310
    
    public_html/wp-includes/plugin.php line 205
    
    public_html/wp-includes/pluggable.php line 1396
    
    public_html/wp-content/plugins/ultimate-member/includes/um-short-functions.php line 608
    
    public_html/wp-content/plugins/ultimate-member/includes/core/um-actions-profile.php line 1399
    
    public_html/wp-includes/class-wp-hook.php line 310
    
    public_html/wp-includes/class-wp-hook.php line 334
    
    public_html/wp-includes/plugin.php line 517
    
    public_html/wp-content/plugins/ultimate-member/includes/core/class-shortcodes.php line 844
    
    public_html/wp-content/plugins/ultimate-member/includes/core/class-shortcodes.php line 633
    
    public_html/wp-includes/shortcodes.php line 395
    
    line
    
    public_html/wp-includes/shortcodes.php line 235
    
    public_html/wp-includes/class-wp-hook.php line 310
    
    public_html/wp-includes/plugin.php line 205
    
    public_html/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php line 1864
    
    public_html/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php line 385
    
    public_html/wp-includes/rest-api/class-wp-rest-server.php line 1188
    
    public_html/wp-includes/rest-api/class-wp-rest-server.php line 1035
    
    public_html/wp-includes/rest-api/class-wp-rest-server.php line 447
    
    public_html/wp-includes/rest-api.php line 418
    
    public_html/wp-includes/class-wp-hook.php line 310
    
    public_html/wp-includes/class-wp-hook.php line 334
    
    public_html/wp-includes/plugin.php line 565
    
    public_html/wp-includes/class-wp.php line 398
    
    public_html/wp-includes/class-wp.php line 779
    
    public_html/wp-includes/functions.php line 1335
    
    public_html/wp-blog-header.php line 16
    
    public_html/index.php line 17
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in public_html/wp-includes/kses.php on line 1735
    
    [22-Aug-2023 21:51:56 UTC] PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in public_html/wp-includes/kses.php on line 1735
    
    [22-Aug-2023 21:51:56 UTC] PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in public_html/wp-includes/kses.php on line 1735
    
    [22-Aug-2023 21:51:56 UTC] PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in public_html/wp-includes/kses.php on line 1735
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    [22-Aug-2023 21:51:56 UTC] PHP Warning: chmod(): Operation not permitted in public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    
    Please note that the “chmod():Operation not permitted” warnings are because the site is operating in an isolated space where although the user has the proper folder permissions they do not have ownership. This is normal and to be expected. All other warnings in the trace are not.
    Plugin Support yuriinalivaiko

    (@yuriinalivaiko)

    Hello @projecta

    Thank you for this info. Now I see that redirecting to the homepage is caused by the um_pre_profile_shortcode function. This function may redirect home if a logged out user tries to access the User page directly. Try to use a code snippet to disable this function for the REST requests.

    // disable rediract profile to home page for the REST request.
    add_filter( 'um_pre_args_setup', function( $args ) {
    	if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
    		remove_action( 'um_pre_profile_shortcode', 'um_pre_profile_shortcode' );
    	}
    	return $args;
    } );

    Regards

    Plugin Support andrewshu

    (@andrewshu)

    Hi @projecta

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread if any other questions come up and we’d be happy to help. ??

    Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘302 redirect on API endpoint’ is closed to new replies.