• Resolved Steven

    (@shazahm1hotmailcom)


    What is the correct method to determine, via PHP, if the user is using the Frontend Editor?

    I came up with this:

    if ( function_exists( 'vchelper' ) ) {
    
    	$sourceId = intval( vchelper( 'Request' )->input( 'vcv-source-id' ) );
    
    	if ( $sourceId === get_the_ID() ) {
    
    		$apply = false;
    	}
    }

    This does seem to work, but I am wondering if there is a supported API for devs to use.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Steven

    (@shazahm1hotmailcom)

    Please ignore the $apply = false; line, that is just for my use… thanks

    Plugin Contributor Edgars V

    (@veidenbaums)

    Hi!

    You can do it by using our FrontEnd helper

    $frontendHelper = vchelper('Frontend');
    if($frontendHelper->isFrontend()) {
        //do the needed stuff
    }
    

    But most likely you want to detect if the page is editable, and you will need this method

    $frontendHelper = vchelper('Frontend');
    if($frontendHelper->isPageEditable()) {
        //do the needed stuff
    }
    

    Let me know if that helped you.

    • This reply was modified 5 years, 1 month ago by Edgars V.
    Thread Starter Steven

    (@shazahm1hotmailcom)

    Yes, isPageEditable() is what I was looking for, thanks! I wasn’t sure how to get that in scope It works perfect for my needs.

    Plugin Contributor Edgars V

    (@veidenbaums)

    Glad that it helped you!

    Feel free to leave a review for our plugin after you have get know it closer. ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Correct method to determine if using Frontend editor.’ is closed to new replies.