Forum Replies Created

Viewing 15 replies - 1 through 15 (of 20 total)
  • Forum: Plugins
    In reply to: [Polylang] Same Url
    Thread Starter mikelast

    (@mikelast)

    Hi @codestylist thanks for the reply, is there any way to include the language as part of the permalink and therefore remove the -2?

    cheers

    Thread Starter mikelast

    (@mikelast)

    I built my own in the end. I created a folder to store a collection of new avatar images for the user to select from. Clicking on the avatar fired an ajax event which:
    1) validated a nonce
    2) checked it was the users profile
    3) got all the avatar images + filtered the the array based on the ID of the image that the user selected, this allowed me to get the full file path of the selected avatar image
    4) check for the users “avatar” folder, if it doesnt exist create it. If we have an existing avatar image we need to clear it first.
    5) finally copy the image into the “avatar” folder, making sure to name it correctly.

    In order to ouput the avatar selection I created a plugin and page under the profile section

    Thread Starter mikelast

    (@mikelast)

    Yeah go ahead it doesnt sound like its a problem with your plugin per say.

    Thanks for getting back to me

    Thread Starter mikelast

    (@mikelast)

    Hmm, I wonder if that is the issue, because I am using the buddypress registration process, perhaps they conflict in some way.

    With regards to the redirect hook I am using template_redirect.

    Is there anyway to disable registration on your plugin?

    For anyone coming across this with a similar problem, I have found a workaround, but its probably not the best.
    I set the buddypress registration page to register, then I created a new page called registration. I created a page template and put all of the register.php code into (some modifications were required but im not gonna detail them here). I set the registration page to use the new page template I created, but the actual register form would still submit to the buddypress register page. I then added a few functions to set the proper global buddypress signup values, and set up a redirect page to my registration page if we had errors occur during registration. I need to do some further testing, but I was able to create a few new accounts.

    Thread Starter mikelast

    (@mikelast)

    I have managed to solve my issue. I add code and comments below in case anyone finds this post an the answers/code below help them.

    First John, thanks for coming back to me and you’re right it was not an issue relating to your plugin.

    For the xdebug thing, I added this below, so that I could be sure my breakpoints would be hit. This adds a query arguement to the URL

    add_filter( 'cron_request', 'wp_cron_debug', 10 );
    function wp_cron_debug( $args ) {
    
    	$args['url'] = add_query_arg( array(
    		'XDEBUG_SESSION_START' => 'PHPSTORM' // <== replace PHPSTORM with your key
    	), $args['url'] );
    
    	return $args;
    
    }

    This was not helpful, nothing really happened as a result of doing the above so I carried on trying to figure out what was happening. Debugging through the WP Crontrol plugin I noticed that the cron_request timeout was really low, something like 0.001, so after some further googling I discovered some actions + filters that allow me to adjust the length of the curl request process.

    
    add_action('http_api_curl', 'custom_curl_timeout', 9999, 1);
    function custom_curl_timeout( $handle ){
    	curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 10 ); // 30 seconds. Too much for production, only for testing.
    	curl_setopt( $handle, CURLOPT_TIMEOUT, 10 ); // 30 seconds. Too much for production, only for testing.
    }

    // Setting custom timeout for the HTTP request

    
    add_filter( 'http_request_timeout', 'custom_http_request_timeout', 9999 );
    function custom_http_request_timeout( $timeout_value ) {
    	return 10; // 30 seconds. Too much for production, only for testing.
    }

    // Setting custom timeout in HTTP request args

    
    add_filter('http_request_args', 'custom_http_request_args', 9999, 1);
    function custom_http_request_args( $r ){
    	$r['timeout'] = 10; // 30 seconds. Too much for production, only for testing.
    	return $r;
    }

    Finally my breakpoints were being hit

    Thread Starter mikelast

    (@mikelast)

    Further to this, I adjusted a debug setting so that we break on the first line of php hit, the wordpress admin area then output the following error

    You are not allowed to run cron events.

    Thread Starter mikelast

    (@mikelast)

    I was using the latest version of buddypress and the bp-nouveau theme, were you using those during your testing? If not could you test with those and see if you have the same error

    Thread Starter mikelast

    (@mikelast)

    For anyone who stumbles upon this, I have managed to figure out a simple solution so hopefully it will help you as well. Head on over to the stack overflow (link at top)

    Thread Starter mikelast

    (@mikelast)

    You, sir, are an angel – thank you for responding. It never occurred to me that the cookies just expired without any code executing but that makes perfect sense now and explains the reasons why none of my code was properly executing.

    What I need to update is a video chat status, updating from online to offline if the user is away from the computer but forgets to log out. I have adjusted the auth cookie expiry to be about 90 mins. When the user goes through the standard WordPress log out process using wp_logout, I can correctly update the chat status, but I need some way to update it if they are “timed out”

    Thread Starter mikelast

    (@mikelast)

    For anyone wanting to follow the Github thread

    Git Hub Thread

    Thread Starter mikelast

    (@mikelast)

    @ekazda – thanks I’ll do that. and I’ll submit this to their Github as well, hopefully we can get this fixed.

    Thread Starter mikelast

    (@mikelast)

    @ekazda you are correct, we do not have any groups available in the dropdown. So do we just need a patch to get the groups to display?

    Been Googling since my earlier post and found this Git Hub WP REST API post

    At the bottom of the post I saw this

    WordPress itself doesn’t really have APIs for inserting entries with new specific IDs (except in doing imports, and that’s only a “suggestion” and shouldn’t be used here), so I’d think that the REST version certainly would not either.

    Does that mean that I cannot create a post on another site with a specific ID? I am trying to json_encode a specific post from one site and post it through to another using wp_remote_post

    Hey Guys,

    Been through the comments above and managed to fix my authentication issues – however I’m still getting a 400 error (see pasted code below). I am trying to send post 12 to https://autoload.dev I have been through the DB and deleted every reference to post 12.

    Array
    (
        [headers] => Array
            (
                [date] => Thu, 09 Jun 2016 11:43:49 GMT
                [server] => Apache/2.2.29 (Unix) mod_wsgi/3.5 Python/2.7.10 PHP/5.6.10 mod_ssl/2.2.29 OpenSSL/0.9.8zh DAV/2 mod_fastcgi/2.4.6 mod_perl/2.0.9 Perl/v5.22.0
                [access-control-allow-origin] => *
                [access-control-allow-methods] => POST, GET, PUT, DELETE, OPTIONS
                [access-control-allow-headers] => Array
                    (
                        [0] => X-Requested-With, content-type
                        [1] => Authorization
                    )
    
                [x-powered-by] => PHP/5.6.10
                [set-cookie] => PHPSESSID=3d20b969e225f5168b258a6fe94609ad; path=/
                [expires] => Wed, 11 Jan 1984 05:00:00 GMT
                [cache-control] => no-cache, must-revalidate, max-age=0
                [pragma] => no-cache
                [x-content-type-options] => nosniff
                [access-control-expose-headers] => X-WP-Total, X-WP-TotalPages
                [last-modified] =>
                [allow] => GET, POST
                [content-length] => 90
                [connection] => close
                [content-type] => application/json; charset=UTF-8
            )
    
        [body] => {"code":"rest_post_exists","message":"Cannot create existing post.","data":{"status":400}}
        [response] => Array
            (
                [code] => 400
                [message] => Bad Request
            )
    
        [cookies] => Array
            (
                [0] => WP_Http_Cookie Object
                    (
                        [name] => PHPSESSID
                        [value] => 3d20b969e225f5168b258a6fe94609ad
                        [expires] =>
                        [path] => /
                        [domain] => autoload.dev
                    )
    
            )
    
        [filename] =>
    )

    Can anyone explain what's going on

    Thread Starter mikelast

    (@mikelast)

    Yep – that was it, I had managed to overwrite it. Thanks for the assist.

    In case anyone else is having similar issues, I just used the below code in my functions.php file to double check

    var_dump($_SERVER['HTTP_HOST']);

    this will output your web address towards the top of the page

Viewing 15 replies - 1 through 15 (of 20 total)