Support » Plugin: Paid Memberships Pro » Customizing via a Custom Plugin

  • Resolved diondkb

    (@diondkb)


    Hi,

    I followed the instructions at this url – https://www.paidmembershipspro.com/documentation/templates/, but get an error when loading the plugin. The error is ‘Fatal error: Cannot redeclare pmpro_shortcode_account() (previously declared …’.

    function my_pmpro_pages_shortcode_pmpro_account($content)
    {
    	ob_start();
    	include(plugin_dir_path(__FILE__) . "templates/pmpro_account.php");
    	$temp_content = ob_get_contents();
    	ob_end_clean();
    	return $temp_content;
    }
    add_filter("pmpro_pages_shortcode_account", "my_pmpro_pages_shortcode_pmpro_account");

    I want to overwrite the password and profile url.

    Any help would be appreciated.

    Dion

Viewing 4 replies - 1 through 4 (of 4 total)
  • pbrocks

    (@pbarthmaier)

    Hi Dion,

    This type of error is related to the requirement for php to have unique functions in order to run properly. What you can simple do is to rename the function and it will run. There isn’t anything magical about the NAME of the function; what matters is that you run on the proper hook and that you pass in the $content argument. Go for something like this:

    function my_second_pmpro_pages_shortcode($content)
    {
    	ob_start();
    	include(plugin_dir_path(__FILE__) . "templates/pmpro_account.php");
    	$temp_content = ob_get_contents();
    	ob_end_clean();
    	return $temp_content;
    }
    add_filter("pmpro_pages_shortcode_account", "my_second_pmpro_pages_shortcode");

    Hi,

    Thanks for the reply. I think the problem is that pmpro_account.php contains the function pmpro_shortcode_account() which at that stage has already been loaded. Its as if the included file(in the customisation plugin), “plugin_dir_path(__FILE__) . “templates/pmpro_account.php” is loaded twice, the first being the original and the second time the one I have adjusted?

    Plugin Author Andrew Lima

    (@andrewza)

    Is this throwing an error on your site?

    If so I would recommend in renaming the pmpro_shortcode_account function to something like pmpro_shortcode_account_custom.

    This should resolve the issue of redeclaring function names.

    Hi Andrew. Not sure where you found that function – pmpro_shortcode_account. I thought the idea behind this all is to replace the original file – pmpro-account.php, or pmpro-checkout.php etc with your file of the same name, but with your changes, saved in the template folder off of the pmpro-customizations sub directory. This is how I understand this link – https://www.paidmembershipspro.com/documentation/templates/customizing-via-a-custom-plugin/

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Customizing via a Custom Plugin’ is closed to new replies.