• This code works in the function.php but when I try to include it as a code snippet when I save I get

    Forbidden

    You don’t have permission to access /wp-admin/admin.php on this server.

    Any idea why please ?

    /* this is to create a custom field*/
    add_action ( ‘bbp_theme_before_topic_form_content’, ‘bbp_extra_fields’);
    function bbp_extra_fields() {
    $value = get_post_meta( bbp_get_topic_id(), ‘bbp_extra_field1’, true);
    echo ‘<label for=”bbp_extra_field1″>hashtag</label><br>’;
    echo “<input type=’text’ name=’bbp_extra_field1′ value='”.$value.”<br>’>”;
    $value = get_post_meta( bbp_get_topic_id(), ‘bbp_extra_field2’, true);
    echo ‘<br><label for=”bbp_extra_field1″>Twitter Name</label><br>’;
    echo “<input type=’text’ name=’bbp_extra_field2′ value='”.$value.”‘>”;
    }

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hi Clive,

    Do you get this error page when saving a simpler snippet, like this one?

    add_action ( 'bbp_theme_before_topic_form_content', function () {
    	echo 'before topic form';
    }
    Thread Starter Clivesmith

    (@clivesmith)

    Hi Shea, thank you, the plugin is not working at all now, I added the action you gave me and and I get a blank page, I used the define(‘CODE_SNIPPETS_SAFE_MODE’, true); to get back.
    I have disabled all the snippets and the page loads when I enable any, including the one above I get a blank page.

    Thread Starter Clivesmith

    (@clivesmith)

    Hi,

    I have had some more problems and in the end I have deleted my test website and re installed it from backup.

    I have installed the code snippet plugin and only added the one you suggest above. I am still getting a blank page. When I saved the snippet I got a message on my browser that something on the page was slowing my browser.

    Adding the line define(‘CODE_SNIPPETS_SAFE_MODE’, true); to the wp-config.php worked after a while (caching).

    but adding the snippet from my first post above still gives me the forbidden page

    • This reply was modified 6 years, 4 months ago by Clivesmith.
    • This reply was modified 6 years, 4 months ago by Clivesmith.
    • This reply was modified 6 years, 4 months ago by Clivesmith.
    Plugin Author Shea Bunge

    (@bungeshea)

    My mistake, the snippet I posted above had a bit left off the end.

    Please try this code instead:

    add_action ( 'bbp_theme_before_topic_form_content', function () {
    	echo 'before topic form';
    } );
    Thread Starter Clivesmith

    (@clivesmith)

    Hi,

    yep your piece of code does not give me forbidden page.

    Clive

    Plugin Author Shea Bunge

    (@bungeshea)

    It looks like the forbidden page is only showing up when snippets you add have an error in them.

    Try using this cleaned-up version of your original snippet:

    add_action( 'bbp_theme_before_topic_form_content', function () {
    	$value = get_post_meta( bbp_get_topic_id(), 'bbp_extra_field1', true );
    	echo '<label for="bbp_extra_field1">hashtag</label><br>';
    	printf( '<input type="text" name="bbp_extra_field1" value="%s"><br>', $value );
    
    	$value = get_post_meta( bbp_get_topic_id(), 'bbp_extra_field2', true );
    	echo '<br><label for="bbp_extra_field1">Twitter Name</label><br>';
    	printf( '<input type="text" name="bbp_extra_field2" value="%s">', $value );
    } );
    Thread Starter Clivesmith

    (@clivesmith)

    HI,
    Thanks, but that gives me the same error message

    Clive

    Plugin Author Shea Bunge

    (@bungeshea)

    I’m really not sure what could be causing this. I have a feeling that it might be something specific to your server configuration, as the code I posted seems to work just fine when I test it out.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Forbidden page on save’ is closed to new replies.