Forum Replies Created

Viewing 11 replies - 16 through 26 (of 26 total)
  • Sorry usernsw, that would be a fair bit of hacking, and would require setting up a test system. But if you google around the problem, you may find similar code snippets – search for “send cookies with file_get_contents” or similar.

    One of the things you’ll find with WP development is that, as flexible as plugins are, there comes a point where you just have to learn PHP. But it’s worth it, I promise ??

    Heh. In general I’d recommend being wary about changing the db format on live systems, since it is probably quite optimised as it is (for the general case, admittedly). But if it is for study, then it’s fine ??

    Move the if statement that defines $curauth to the start of your callback function.

    Forum: Hacks
    In reply to: Select fields and widgets

    Not too familar with widget development, but nevertheless: I’d trace how this data is being saved. In your plugin, do this:

    if ($_POST) {
        echo "<pre>" . print_r($_POST, true) . "</pre>";
        exit();
    }

    That’ll let you see if the form values are coming back okay (I’m presuming it’s a POST form).

    If that’s good then you’ll need to look at the save code (presumably this is part of WP?). I’d put your whole site in version control, and then you can easily add echo/exit/debug statements around WP to your hearts content (and it’s easy to revert).

    I don’t think this would be appropriate in all cases. If you look at the param signature for add_user_meta:

    add_user_meta( $user_id, $meta_key, $meta_value, $unique );

    The last parameter specifies whether the meta item must be unique. For example adding ‘nickname’ would be non-unique, since a person may have several nicknames. I should think the index you’re proposing would cause problems with some plugins, but you may get a performance improvement if you’re sure it will work for your site.

    Ha ha, no worries! Glad you figured it out.

    Well, I dunno about the proper way, but if this is your plugin PHP file:

    <?php
    // Put this at the start of your plugin file
    echo "I got called!\n";

    Inelegant, but it works ??

    Forum: Hacks
    In reply to: passing url traking codes

    Would you provide more info on how “wordpress seems to remove the url parameters”? I am not sure this is quite clear.

    Are you creating custom Piwik functionality, or are you using a WP plugin? I believe there are ready-made Piwik plugins, which should report your ad campaigns correctly.

    Forum: Hacks
    In reply to: automated testing borked

    Can you get Selenium to click on “/wp-admin/media-new.php?browser-uploader” prior to running the tests?

    Seems to work for me (stripped out of some of my current work in progress, so sorry if I’ve missed a bit of code):

    class CommentsEncryptMain
    {
    	public function __construct()
    	{
    		$this->initScreens()
    	}
    
    	protected function initScreens()
    	{
    		// Set up handler for admin screen hook
    		add_action('admin_menu', array($this, 'screensHandler'));
    
    		// Set up handler for admin bar registration (100 = put menu item at the end of standard items)
    		add_action('admin_bar_menu', array($this, 'adminBarRegister'), 100);
    	}
    
    	public function adminBarRegister(WP_Admin_Bar $WpAdminBar)
    	{
    		$privKeySet = (bool) $_COOKIE[self::COOKIE_PRIV_KEY];
    
    		$WpAdminBar->add_menu(
    			array(
    				'id' => 'encdemo_key_status',
    				'title' => $privKeySet? 'Private key set' : 'Private key unknown',
    				'href' => 'edit-comments.php?page=xyz',
    			)
    		);
    	}
    }
    
    new CommentsEncryptMain();

    If that doesn’t help, can you confirm that your plugin is actually activated, and is called for admin screens?

    Try this. If you login as normal to https://mytargeturl.com in your usual browser, try accessing the same URL in a different browser, but with your session name and value as you have them in your question. Unless your site is specifically set up to recognise this, I don’t think this will log you on.

    Questions: is the site (mytargeturl) a WordPress site? Is the site from which you are making this call a WordPress site?

    What you are trying to do is possible, but not completely trivial. I suspect you will need to pass to the external site your cookie(s) that you get upon logging in – using file_get_contents() is effectively like using a new browsing session, and is disconnected from you being logged in elsewhere.

    Take a look at the third param to file_get_contents(), which is $context. You’ll need to create a stream context containing the cookies in the header, using stream_context_create(). The php docs are quite good here.

    Let us know how you get on!

Viewing 11 replies - 16 through 26 (of 26 total)