Looked into this for about an hour and so far I have this:
<?php
/**
* Plugin Name: Redirect To Page
* Description: A simple plugin for redirecting non-admins to a specific page.
*/
add_action('admin_menu', 'rtp_plugin_settings');
function rtp_plugin_settings() {
add_menu_page('Redirect Settings', 'Redirect Settings', 'administrator', 'rtp_settings', 'rtp_display_settings');
}
function rtp_display_settings() {
$pageurl = (get_option('rtp_pageurl') != '') ? get_option('rtp_pageurl') : '2000';
$enableredirect = (get_option('rtp_enabled') == 'enabled') ? 'checked' : '' ;
$html = '</pre>
<div class="wrap"><form action="options.php" method="post" name="options">
<h2>Redirect Settings</h2>
' . wp_nonce_field('update-options') . '
<table class="form-table" width="100%" cellpadding="10">
<tbody>
<tr>
<td scope="row" align="left">
<label>Enable Redirect</label>
<label> </label>
<input type="checkbox" name="rtp_enabled" value="enabled" /></td>
</tr>
<tr>
<td scope="row" align="left">
<label>Page URL</label>
<label> </label>
<input type="text" name="rtp_pageurl" value="' . $pageurl . '" />
</td>
</tr>
</tbody>
</table>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="enableredirect, rtp_pageurl" />
<input type="submit" name="Submit" value="Update" /></form></div>
<pre>
';
echo $html;
}
My main issue now is that I cannot seem to get another function added without an error and the plugin going inactive.
Would you know how to finish this (or add the function)?
P.S: Try to bare with me, I am more than fluent in Javascript, UnityScript and quickly learning C#, but this is my absolute first time with php, and making WordPress plugins so try to bare that in mind if my code is complete gibberish.