$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>rest api - Create a new page on front page for logged in user|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

rest api - Create a new page on front page for logged in user

matteradmin9PV0评论

I am going to find a way for logged in users to create pages from front page. For example there are three buttons so called button1,2,3. When logged in users clicks on button1, a page with title newyork1 is created and if user clicks on New York button for one more time, a new page newyork1-1 and newyork1-2 are created and the same logical with Tokyo and London. I have tried Wordpress Rest API then wp_insert_post() function but it not working as it cannot get the author and title as i aspected. If you guys have a better idea, please help. Thank you

<ul> 
    <li> <a href="" data-name="newyork"> New York</a></li> 
    <li> <a href="" data-name="tokyo"> Tokyo</a></li>
    <li> <a href="" data-name="london"> London</a></li>
</ul>

I am going to find a way for logged in users to create pages from front page. For example there are three buttons so called button1,2,3. When logged in users clicks on button1, a page with title newyork1 is created and if user clicks on New York button for one more time, a new page newyork1-1 and newyork1-2 are created and the same logical with Tokyo and London. I have tried Wordpress Rest API then wp_insert_post() function but it not working as it cannot get the author and title as i aspected. If you guys have a better idea, please help. Thank you

<ul> 
    <li> <a href="" data-name="newyork"> New York</a></li> 
    <li> <a href="" data-name="tokyo"> Tokyo</a></li>
    <li> <a href="" data-name="london"> London</a></li>
</ul>
Share Improve this question asked Jan 31, 2019 at 9:15 TonyTony 12 bronze badges 1
  • Hi @Tony, your question is too vague and not appropriate for this forum, you are unlikely to get any answers. You are seeking to solutions to your specific problem, and not to a general WP functionality problem. Questions which have a real value for the rest of the community (ie that others may face too) are more likely to get you answers. – Aurovrata Commented Feb 1, 2019 at 8:55
Add a comment  | 

2 Answers 2

Reset to default 0

How about redirecting specific users with a set of redirect rules? You can try using Peter’s Login Redirect plugin. Follow these steps:

  1. Install and activate the plugin.
  2. Hover on Settings in the left sidebar.
  3. Click on Login/logout redirects.
  4. Enter your custom Login URL for specific users.

Already has a solution here You have modify a bit to use it. 1. 'post_type' => 'post', change to 'post_type' => 'page',

Also your user must have capabilities to create page. Here is another solution on how to handle that.

Post a comment

comment list (0)

  1. No comments so far